“Django Redirect” Kode Jawaban

Redirect Django

from django.shortcuts import redirect

def my_view(request):
    # ...
    return redirect('some-view-name', foo='bar')
mohammed_samir

impor get_object_or_404

from django.shortcuts import get_object_or_404
Virgin Programmer

Redirect di Dajango

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')
Grumpy Gemsbok

Django Redirect

from django.shortcuts import render, redirect

def redirecting(request):
	return redirect("https://codingtutz.com/")
Unsightly Unicorn

Redirect di Dajango

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')
Grumpy Gemsbok

Jawaban yang mirip dengan “Django Redirect”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya