[Fixed]-Three functions, one template

1👍

The solution is to make three urls, each url point to a method.

urlpatterns = patterns('',

url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'dApp.views.funcion'),
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'index.html'}, name='login'),
url(r'^logout$', 'django.contrib.auth.views.logout_then_login', name='logout')                

)

0👍

my understanding about your question is, you need to add login and log out in index.html
when you run the “dApp.views.funcion”.

first of all : you can’t add urls in this format , you need to add some index.

urlpatterns = patterns('',

    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', 'dApp.views.funcion'),
    url(r'^/login/$', 'django.contrib.auth.views.login', {'template_name': 'index.html'}, name='login'),
    url(r'^/logout/$', 'django.contrib.auth.views.logout_then_login', name='logout')                
)

call “{% url ‘login’ %} and {% url ‘logout’ %} in template , this answer is my understanding about your question.

Leave a comment