[Django]-Django, How to pass data object from one template to another template

6👍

You can write another view to handle your requirement

Try this sample code

URL

# pass the selected school id form template to your view   
url(r'^school/(?P<school_id>\d+)/$', schoolDetails), 

views

def schoolDetails(request, school_id):
    try:
        school = PublicSchools.objects.get(pk=school_id)
    except school.DoesNotExist:
        raise Http404
    return render(request, 'detail.html', {'school': school})

Hope this helps you 🙂

Leave a comment