creamidea / Mushroom

To display Node Capture Data and Control it
Other
0 stars 1 forks source link

Django 像在模板中使用url那样在code中使用 #3

Open creamidea opened 10 years ago

creamidea commented 10 years ago

很简单。

from django.core.urlresolvers import reverse

def myview(request):
    return HttpResponseRedirect(reverse('arch-summary', args=[1945]))
# reverse()
#If you need to use something similar to the url template tag in your code, Django provides the following function:

reverse()返回的就是那个url。

Reference:

creamidea commented 10 years ago

32