Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.contrib.auth.hashers import make_password
- from django.db import models
- from django.utils.translation import gettext_lazy as _
- from django.contrib.auth import models as auth_models
- from django.utils import timezone
- from my holiday.accounts.managers import MyHolidayUserManager
- class MyHolidayUser(auth_models.AbstractBaseUser, auth_models.PermissionsMixin):
- email = models.EmailField(
- _("email address"),
- unique=True,
- error_messages={
- "unique": _("A user with that email already exists."),
- },
- )
- date_joined = models.DateTimeField(_("date joined"), default=timezone.now)
- is_staff = models.BooleanField(
- default=False,
- )
- is_active = models.BooleanField(
- default=True,
- )
- USERNAME_FIELD = "email"
- objects = MyHolidayUserManager()
- class Profile(models.Model):
- MAX_USERNAME_LENGTH = 20
- first_name = models.CharField(
- max_length=50,
- null=True,
- blank=True,
- verbose_name='First Name',
- )
- last_name = models.CharField(
- max_length=50,
- null=True,
- blank=True,
- verbose_name='Last Name',
- )
- age = models.IntegerField(
- null=False,
- blank=False,
- verbose_name='Age',
- )
- profile_photo = models.URLField(
- null=True,
- blank=True,
- verbose_name='Profile Photo',
- )
- user = models.OneToOneField(
- MyHolidayUser,
- primary_key=True,
- on_delete=models.CASCADE,
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement