Thursday, May 21, 2020

Re: How to Insert Foreign Key into my user model with Abstractbaseuser

You Can Try this one
 user = models.ForeignKey(User, on_delete=models.CASCADE)

On Thu, May 21, 2020 at 5:41 PM 박지훈 <llet1019@gmail.com> wrote:
class User(AbstractBaseUser):
password = models.CharField(max_length=128)
username = models.CharField(unique=True, max_length=150)
is_superuser = models.IntegerField()
last_name = models.CharField(max_length=150)
phone = models.CharField(max_length=20)
email = models.CharField(max_length=254)
date_of_birth = models.DateTimeField()
date_joined = models.DateTimeField()
last_login = models.DateTimeField(blank=True, null=True)
is_staff = models.IntegerField(blank=True, null=True)
is_active = models.IntegerField(blank=True, null=True)
first_name = models.CharField(max_length=30, blank=True, null=True)


objects = UserManager()

USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['last_name', 'phone', 'email', 'date_of_birth']

def has_perm(self, perm, obj=None):
return True

def has_module_perms(self, app_label):
return True

class Meta:
db_table = 'auth_user'

This is my user model in app.models.py 

I want to add foreign key into Class User. but i can`t ...

please help me

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8389b104-c5f0-4936-b8ea-0ec9a82a5460%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANaPPPJciGr2R%2BMDHxcg%3DKfU1RT%3D%3DEnAGGtb759EEkz-W4fVjg%40mail.gmail.com.

No comments:

Post a Comment