python - how to get url of app in django -
how can url path app
def logout(request): auth.logout(request) # path defined app in projects urls.py return httpresponseredirect('??????')
i know can hard code how can it?
urls.py file
urlpatterns = patterns('', url(r'^chat/',include('djangochat.urls')),
djangochat.urls.py file
urlpatterns = patterns('', url(r'^$', views.index, name='index'), url(r'^login/$',views.login,name='login'), url(r'^logout/$',views.logout,name='logout') )
i want logout method redirect /chat
path views.index method gets called
to reverse lookup url name, do:
from django.core.urlresolvers import reverse def logout(request): auth.logout(request) return httpresponseredirect(reverse('index'))
Comments
Post a Comment