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.
- Python webframework django noreversematch
- Django REST: Creating db entries in related table in one POST
- How to pass the values from the template as an argument to the function in views?
Source:stackexchange.com