Hi Arun,

If you only want to log failed login attempts I suggest you connect a 
receiver to
the user_login_failed signal[1] instead.

Cheers,
Simon

[1] 
https://docs.djangoproject.com/en/1.9/ref/contrib/auth/#django.contrib.auth.signals.user_login_failed

Le mardi 3 mai 2016 06:01:59 UTC-4, Arun S a écrit :
>
> Hi,
>
> I was trying to add a Customised View to Handle Wrong Passwords entered by 
> Users.
>
> As of now, Djangos Framework just outputs, "Invalid Username or Password" 
> when a Wrong password is entered by the User.
>
> This doesnt allow much flexibility if some information such as Invalid 
> Access needs to be Logged.
> Thus it would be good to Redirect these into a Customized view where the 
> Logging of such information can be done and then redirected back to the 
> Login page with Error.
>
> Any Ideas on how easily this can be done ?
>
> I tried adding a View when a Wrong password is called but always ended up 
> in the below Error:
>
>   File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", 
> line 578, in reverse
>     return force_text(iri_to_uri(resolver._reverse_with_prefix(view, 
> prefix, *args, **kwargs)))
>   File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", 
> line 495, in _reverse_with_prefix
>     (lookup_view_s, args, kwargs, len(patterns), patterns))
> NoReverseMatch: Reverse for '' with arguments '()' and keyword arguments 
> '{}' not found. 0 pattern(s) tried: []
>
>
> The login.html looks as simple as this.
> td>{{ form.password }}
>                                 {% if form.password.errors %}
>                                       <div id="password_error_div" 
> class="error">You must specify a password.</div>
>                                   {% endif %}
>                                   
>
> *{% if form.non_field_errors %}                                  <div 
> id="password_error_div" class="error">Invalid username or 
> password.</div>                                  {% endif %}*
>                           </td>
> In the Highlighted case, i would like to handle the Error, Log the 
> information to a file required and return back to the page.
>
> Any Help on how this can be done would be great.
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5d01cf5f-87eb-4f2c-acb0-106b49068596%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to