from django.shortcuts import redirect
from .models import Element
def element_info(request):
# ...
element = Element.object.get(pk=1)
return redirect('element_update', pk=element.id)
def element_update(request, pk)
# ...
from django.shortcuts import redirect
def my_view(request):
# ...
return redirect('some-view-name', foo='bar')
from django.shortcuts import render, redirect
def redirecting(request):
return redirect("https://codingtutz.com/")
from django.shortcuts import render
def my_view(request):
# View code here...
return render(request, 'myapp/index.html', {
'foo': 'bar',
}, content_type='application/xhtml+xml')
def my_view(request):
...
return redirect('/some/url/')
from django.shortcuts import redirect
from django.http import HttpResponse
from django.template import loader
def my_view(request):
# View code here...
t = loader.get_template('myapp/index.html')
c = {'foo': 'bar'}
return HttpResponse(t.render(c, request), content_type='application/xhtml+xml')