Django how to get password after registration form is submitted?

jeff

I'm trying to edit django-registration's RegistrationFormUniqueEmail form, which currently looks like the following:

class RegistrationFormUniqueEmail(RegistrationForm):
    """
    Subclass of ``RegistrationForm`` which enforces uniqueness of
    email addresses.

    """
    def clean_email(self):
        """
        Validate that the supplied email address is unique for the
        site.

        """
        if User.objects.filter(email__iexact=self.cleaned_data['email']):
            raise forms.ValidationError(validators.DUPLICATE_EMAIL)
        return self.cleaned_data['email']

I want to implement a form that checks if the password has a number and a special character, but I'm failing to get the password? I'm not sure if it's even possible, but here is what I tried to get the password:

self.cleaned_data['id_password2']
self.cleaned_data['password2']
self.cleaned_data['password']
self.cleaned_data.get('id_password2')
self.cleaned_data.get('password2')
self.cleaned_data.get('password')

all of these return a NoneType object.

I also tried to define a clean_password2 function, but no help. Is this doable? And how so?

Thanks for any help,

dan arters

Cleaned data isn't an attribute when you create a form, it is added when you call is_valid() on a form.

is_valid() will check that the data conforms to the constraint you put on it when creating the form (in this case, matching passwords and unique email by default for a RegistrationFormUniqueEmail). It might make sense to overwrite the is_valid() or create another function that calls is_valid() in addition to performing additional checks on password strength, instead of performing additional validation outside of the standard procedure

def custom_is_valid(self):
    valid = self.is_valid()
    if password.is.not.secure():
        self.add_error('password', ValidationError(('Insecure Password'), code='invalid'))
        valid = False
    return valid

The above snipped might do the trick. The string 'password' in adding the error tacks it onto the form field you indicate, you may want to use password1 or password2 because I think that's the field name for the build in form you're using. Also, you wouldn't use cleaned_data to check password validity. You would just use the data attribute, form.data['password']

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I get the rest of a django-registration password reset form?

From Dev

How to get the submitted value of a form in a Django class-based view?

From Dev

NoReverseMatch: in the password reset form in Django-registration?

From Dev

django - no password set after successful registration

From Dev

How to subclass registration form in django-registration

From Dev

why I get three password fields when I define my custom registration form in Django?

From Dev

How to make django registration form

From Dev

PHP - How to hide the form after it's submitted

From Dev

How to get the name of a submitted form in Flask?

From Dev

Angularjs, how to get submitted form data dynamically

From Dev

How to get submitted form data in codeigniter?

From Dev

sendEmail after form submitted

From Dev

How to get a Django Prepopulated Model Form for User to *not* populate password

From Dev

Removing second password input from django-registration form

From Dev

Removing second password input from django-registration form

From Dev

django get token and userid after successful registration

From Dev

Why does form get submitted after onsubmit return undefined?

From Dev

How to use django countries in registration form?

From Dev

How to create a profile registration form in Django?

From Dev

Django Registration Registration_form

From Dev

How to Get my own Page after Login in joomla User Registration form

From Dev

How to customise drupal 7 user registration, login, password reset form

From Dev

How to keep the dropdown menu selected value after form is submitted?

From Dev

How to reset a form to pristine after submitted in Angular JS

From Dev

How to handle jQuery error after form is submitted to itself

From Dev

How would I make a message pop up after this form is submitted?

From Dev

How to show a dropdown menu filter selected value after form is submitted?

From Dev

How to remove form after it's submitted in Laravel PHP?

From Dev

How to redirect if form is not submitted

Related Related

  1. 1

    How can I get the rest of a django-registration password reset form?

  2. 2

    How to get the submitted value of a form in a Django class-based view?

  3. 3

    NoReverseMatch: in the password reset form in Django-registration?

  4. 4

    django - no password set after successful registration

  5. 5

    How to subclass registration form in django-registration

  6. 6

    why I get three password fields when I define my custom registration form in Django?

  7. 7

    How to make django registration form

  8. 8

    PHP - How to hide the form after it's submitted

  9. 9

    How to get the name of a submitted form in Flask?

  10. 10

    Angularjs, how to get submitted form data dynamically

  11. 11

    How to get submitted form data in codeigniter?

  12. 12

    sendEmail after form submitted

  13. 13

    How to get a Django Prepopulated Model Form for User to *not* populate password

  14. 14

    Removing second password input from django-registration form

  15. 15

    Removing second password input from django-registration form

  16. 16

    django get token and userid after successful registration

  17. 17

    Why does form get submitted after onsubmit return undefined?

  18. 18

    How to use django countries in registration form?

  19. 19

    How to create a profile registration form in Django?

  20. 20

    Django Registration Registration_form

  21. 21

    How to Get my own Page after Login in joomla User Registration form

  22. 22

    How to customise drupal 7 user registration, login, password reset form

  23. 23

    How to keep the dropdown menu selected value after form is submitted?

  24. 24

    How to reset a form to pristine after submitted in Angular JS

  25. 25

    How to handle jQuery error after form is submitted to itself

  26. 26

    How would I make a message pop up after this form is submitted?

  27. 27

    How to show a dropdown menu filter selected value after form is submitted?

  28. 28

    How to remove form after it's submitted in Laravel PHP?

  29. 29

    How to redirect if form is not submitted

HotTag

Archive