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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -