简体   繁体   中英

Multiple Views on one template in Django

Essentially I want to have a login on my home page. The login view is found in "django.contrib.auth.views.login" which I don't believe I have access to. But then it also needs to have a view which deals with all the other bits going on on the home page. I would combine these into one view but since I don't appear to have access to the login views I dont think I can do this.

If there is another way of doing this rather than having two views on one template that would be great I'm quite new to web deving so I'm not sure of what the "right" way to do things is.

Many thanks

def index_view(request):
    return render(request, 'homepage.html')

In your homepage.html just pass django login url

<form name="form" method="post" action="{% url 'django.contrib.auth.views.login' %}">

Updates

Please include url also

(r'^accounts/login/$', 'django.contrib.auth.views.login'),

Please follow this login for more details...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM