Answer the question
In order to leave comments, you need to log in
Why Django error?
It is necessary to extend the standard User model. Here is the model:
class Post(AbstractUser):
post = models.CharField(max_length=500)
user = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
user_pk = models.IntegerField(default=0)
user_send = models.IntegerField(default=0)
def __str__(self):
return str(self.created)
Answer the question
In order to leave comments, you need to log in
Hello) Oh, the question is two years old, but just in case I will answer.
I faced the same problem today, there are two options:
1. Delete the database and migration and recreate it (with the command python manage.py makemigrations, python manage.py migrate), but unfortunately in my case it did not work ...
2. Replace the word User with settings.AUTH_USER_MODEL, and don't forget to import settings(from django.conf import settings)
models.py
from django.conf import settings
class Post(AbstractUser):
post = models.CharField(max_length=500)
user = models.ForeignKey(settings.AUTH_USER_MODEL)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
user_pk = models.IntegerField(default=0)
user_send = models.IntegerField(default=0)
def __str__(self):
return str(self.created)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question