[Django]-Django generate URL from View

7👍

You can do that using reverse() in the views.

teams.append({"title":fields["title"] ,  
    "url": reverse("team_wall", {'teamid':teamID}))

I’m assuming teamID is the team id that can be passed to the view.

👤Rohan

1👍

It can be done using “reverse” function:

https://docs.djangoproject.com/en/dev/ref/urlresolvers/#reverse

from django.core.urlresolvers import reverse

def myview(request):
    return HttpResponseRedirect(reverse('arch-summary', args=[1945]))

Leave a comment