Redirect and a different html page being called, but same url

会有一股神秘感。 提交于 2019-12-25 08:38:24

问题


I'm working through various Django tutorials in order to get an LDAP Backend up and running. I have a simple login page using a user's credentials, and an extra field to insert a user to be searched for. When hitting the submit button on my page, I get redirected to the correct html, but the url remains the same. I'm not sure that this could pose any problems, but if not, does it really matter if a different page has the same url? How should I be calling the redirected page?

urls.py

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', ldap_authentication, name='index'),
    url(r'^logout/$', logout_view, name='logout'),
    url(r'^search_page/$', ldap_authentication, name="search_page")
] 

views.py

def ldap_authentication(request):             
    if request.POST:
        username = request.POST['username']
        password = request.POST['password']
        searchFilter = request.POST['searchUser']
        domain_and_login = '{}\\{}'.format(DOMAIN_NAME, username)

    '''
    Connection to LDAP...
    '''
    split_dn = [domain_and_login, "ou=Konzern", "dc=abcdef", "dc=de"]
    return render(request, 'search_page.html', {'dn':split_dn})

return render(request, 'login.html')

If I do a redirect, then I understand that Django looks this up in the urls.py, however the search_page.html doesn't have any view in the views.py.

来源:https://stackoverflow.com/questions/44869975/redirect-and-a-different-html-page-being-called-but-same-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!