My use AbstractUser from django default table user… my like create table Profile inline from User Custom AbstractUser. How to separate models user/profile?
profile.models
from django.db import models
class Profile(models.Model):
models.py → User custom model
from django.db import models
from django.contrib.auth.models import AbstractUser, PermissionsMixin
from django.utils.translation import gettext_lazy as _
from stdimage import StdImageField
from core.utils import RandomFileName, resize_and_autorotate
class User(AbstractUser, PermissionsMixin):
GENDER = (
("Male", _('Male')),
("Female", _('Female')),
("n/a", _('n/a')),
)
photo =StdImageField(upload_to=RandomFileName("photo/"), delete_orphans=True, render_variations=resize_and_autorotate, blank=True , variations={'avatar': (120, 120, True),})
email =models.EmailField(_('Email address'), unique=True, error_messages={'unique':_("This email has already been registered.")})
gender =models.CharField(choices=GENDER, default='n/a',max_length=50, verbose_name=_('Gender'))
birthday =models.DateField(null=True, blank=True, verbose_name=_('Birthday'))
info =models.TextField(verbose_name=_("information user"))
city =models.CharField(_('City'), null=True, blank=True,max_length=255)
location =models.CharField(_('Location'), null=True, blank=True,max_length=255)
phone =models.CharField(_('Phone'), null=True, blank=True,max_length=255)
USERNAME_FIELD = 'username'
EMAIL_FIELD = 'email'
REQUIRED_FIELDS = ['first_name', 'last_name', 'email']
def save(self, *args, **kwargs):
super(User, self).save(*args, **kwargs)
Thanks.
Good night.