python - user authentication problem in django -
I'm new to Python and Django. I'm trying for a secure user authentication, which uses the framework that works. I am in a login.html page [template / user]. And if login success leads to user user / contact facilitates.
ContactSuccess.html: views.py ............ .............. urls.py: < P> The output is: I am using Python 1.3, Python 2.7.2 and Windows 7 I am The problem is whether the value is authenticated to a user, whether it is by the browser Determines - The HTTP authentication stores the user name and password and then makes it less or less for each request to prevent logging from working, you have to tell the browser to stop. There is a good deal of proper information on that topic. Since this is a test environment, and since the authentication headers have some time when you restart the browser, more or less are reset, I close the browser and then open it I recommend ... this will be the easiest.
& lt; Html & gt; --------- {{request.user.username}} ------------ {% if request.user.is_authenticated%} & lt; P & gt; Welcome, {{User. User name}}. Thanks for signing in. & Lt; / P & gt; {% Else%} & lt; P & gt; Welcome, New User Please sign in. & Lt; / P & gt; {% Endif%} & lt; Body & gt; Success & lt; / Body & gt; & Lt; / Html & gt;
Def testlogsuccess (request): & lt; Br / & gt; If not, request.user.is_authenticated (): Return HttpResponseRedirect ("/ accounts / login /") other: user = request.user.is_authenticated () Returns render_to_response ('user / ContactSuccess.html', local ()) < / Code>
urlpatterns = pattern ('', ('r' ^ admin / ', include (admin.site.urls)), (' R account accounts / login / $ ', Login), (R' ^ accounts / logout / $ ', logout), (R' accounting / profile / $ ', views. Testlogsuccess),
The job is fine.
--------- G ------------ Welcome Thank you for entering. .
But my problem occurs when I close my devlopment server and then start it again and then the URL 'http: //127.0. 0.1: 8000 / accounts / profiles / 'without logging, it still shows the above output. How can I avoid it?
Comments
Post a Comment