Django registration redux registration only with email (no password)

Anton Linevych

Is there any way to implement form only with email field (without password and username)? User will receive email with link to confirm his account and set password.

Any information will be helpfull, thanks.

To user Temka:

I've already have cutom RegistrationForm:

from registration.forms import RegistrationForm


class UserForm(RegistrationForm):
    username = forms.CharField(
        max_length=254,
        required=False,
        widget=forms.HiddenInput(),
    )
    password1 = forms.CharField(
        widget=forms.HiddenInput(),
        required=False,
    )

    password2 = forms.CharField(
        widget=forms.HiddenInput(),
        required=False,
    )

    def clean_email(self):
        email = self.cleaned_data['email']
        self.cleaned_data['username'] = email
        return email

    def clean_password2(self):
        pass

Also thanks for "unusable password" info.

Temka

User model

First you need to create custom User manager and model.
Documentation can be found here https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#a-full-example

from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager

class EmailUserManager(BaseUserManager):
    def create_user(self, email, password=None):
        if not email:
            raise ValueError('Users must have an email address')

        user = self.model(email=self.normalize_email(email),)
        user.set_password(password)
        user.save(using=self._db)
        return user

    def create_superuser(self, email, password):
        user = self.create_user(email, password=password,)
        user.is_admin = True
        user.is_superuser = True
        user.save(using=self._db)
        return user


class EmailUser(AbstractBaseUser, PermissionsMixin):
    email = EmailField(
        verbose_name='email',
        max_length=255,
        unique=True,
    )
    is_active = models.BooleanField(default=True)
    is_admin = models.BooleanField(default=False)
    date_joined = models.DateTimeField(default=timezone.now)

    objects = EmailUserManager()

    USERNAME_FIELD = 'email'

    def get_full_name(self):
        return self.email

    def get_short_name(self):
        return self.email

    def __str__(self):
        return self.email

    @property
    def is_staff(self):
        return self.is_admin

And register it in your settings.py with this line AUTH_USER_MODEL = 'app.EmailUser'.
Now your EmailUser model can be used with from django.contrib.auth import get_user_model and from django.conf.settings import AUTH_USER_MODEL.

Example usage (foreign key):

from django.db import models
from django.conf.settings import AUTH_USER_MODEL

class Profile(models.Model):
    class Meta:
        verbose_name = 'Profile'
        verbose_name_plural = 'Profiles'

    user = models.OneToOneField(AUTH_USER_MODEL, verbose_name='User',
                                related_name='profile')
    full_name = models.CharField('Full name', max_length=64, blank=False)
    phone = models.CharField('Phone', max_length=64, blank=True)

Registration

When using django-registration-redux two-step registration:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Django User Registration - Password Reset via email

From Dev

django - no password set after successful registration

From Dev

Django-registration, custom registration and validation

From Dev

user verification email for registration page

From Dev

How to subclass registration form in django-registration

From Dev

validating email in registration is not raising validationError in Django?

From Dev

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

From Dev

Send email confirmation after registration django

From Dev

Removing second password input from django-registration form

From Dev

Email Registration validation in PHP

From Dev

Django Registration Redux custom registration form

From Dev

Django registration redux registration only with email (no password)

From Dev

Django-registration resend activation Email with new code

From Dev

IRC Protocol - Registration to Server with Password

From Dev

Django-Registration-Redux doesn't see my templates/registration templates

From Dev

Django Registration or or django auth?

From Dev

Django-registration, custom registration and validation

From Dev

Removing second password input from django-registration form

From Dev

How to send users their password by email upon registration in classipress?

From Dev

django social auth registration facebook email

From Dev

Jquery email validation in registration

From Dev

Where are Django registration redux defaut files stored

From Dev

Django-registration resend activation Email with new code

From Dev

IRC Protocol - Registration to Server with Password

From Dev

Django-Registration-Redux doesn't see my templates/registration templates

From Dev

Laravel Email Confirmation On Registration

From Dev

Django how to get password after registration form is submitted?

From Dev

Django Redux Registration Incorrect Password / Username when it is correct

From Dev

Django Registration Registration_form

Related Related

  1. 1

    Django User Registration - Password Reset via email

  2. 2

    django - no password set after successful registration

  3. 3

    Django-registration, custom registration and validation

  4. 4

    user verification email for registration page

  5. 5

    How to subclass registration form in django-registration

  6. 6

    validating email in registration is not raising validationError in Django?

  7. 7

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

  8. 8

    Send email confirmation after registration django

  9. 9

    Removing second password input from django-registration form

  10. 10

    Email Registration validation in PHP

  11. 11

    Django Registration Redux custom registration form

  12. 12

    Django registration redux registration only with email (no password)

  13. 13

    Django-registration resend activation Email with new code

  14. 14

    IRC Protocol - Registration to Server with Password

  15. 15

    Django-Registration-Redux doesn't see my templates/registration templates

  16. 16

    Django Registration or or django auth?

  17. 17

    Django-registration, custom registration and validation

  18. 18

    Removing second password input from django-registration form

  19. 19

    How to send users their password by email upon registration in classipress?

  20. 20

    django social auth registration facebook email

  21. 21

    Jquery email validation in registration

  22. 22

    Where are Django registration redux defaut files stored

  23. 23

    Django-registration resend activation Email with new code

  24. 24

    IRC Protocol - Registration to Server with Password

  25. 25

    Django-Registration-Redux doesn't see my templates/registration templates

  26. 26

    Laravel Email Confirmation On Registration

  27. 27

    Django how to get password after registration form is submitted?

  28. 28

    Django Redux Registration Incorrect Password / Username when it is correct

  29. 29

    Django Registration Registration_form

HotTag

Archive