Reputation: 4759
I am trying to use the django app - https://github.com/dstufft/django-passwords, to set up password strength checking for django passwords. Here are things i have done till now:
Installed django-passwords with
pip install django-passwords
Created a form:
from passwords.fields import PasswordField
class ResetForm(forms.Form):
password = PasswordField(label="New password")
confirmPassword = PasswordField(label="Confirm new password")
In settings.py added the field
PASSWORD_MIN_LENGTH = 6
Form shows up fine in the page. When i enter a password which is less than 6 characters, no error appears.
Is there a anything i am missing or anything i should do to get it to work ?
Any help will be really appreciated.
Upvotes: 0
Views: 88
Reputation: 1391
If your code is literarily as you typed in your comment, then the issue is with your code definition. From what you write, your view definition is:
def index(request):
return render_to_response('templateName', {'form': ResetForm})
You never instantiate the form and you new add the POST-data to the form. Change it to:
def index(request):
if request.method == 'POST':
form = ResetForm(data=request.POST)
else:
form = ResetForm()
return render_to_response('templateName', {'form': form})
This should work :-).
Perhaps your better off using the render
method for this includes a RequestContext
object that handles the CSRF token.
More info on this subject: https://docs.djangoproject.com/en/1.8/topics/forms/#the-view
Upvotes: 1