Reputation: 1
The table wasn't created when I made custom user model.
In my settings.py, I installed my app and defined AUTH_USER_MODEL
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
#My apps
'accounts',
]
AUTH_USER_MODEL = 'accounts.User'
my model is below (at accounts app)
class User(AbstractBaseUser):
key = models.AutoField(primary_key=True)
email= models.EmailField('email',unique=True)
name=models.CharField('name',max_length=20) #model.USERNAME_FIELD
is_active=models.BooleanField('is_active',default=True)
is_admin=models.BooleanField('is_admin',default=False)
date_joined = models.DateTimeField('date_joined',default=timezone.now)
objects = UserManager()
USERNAME_FIELD = 'email'
#EMAIL_FIELD = 'email'
class Meta:
swappable = "AUTH_USER_MODEL"
I executed makemigrations && migrate. And I've also tried makemigrations accounts && migrate accounts
but still there is no accounts_user table.
Upvotes: 0
Views: 27
Reputation: 3635
Step-1 delete migration folder
Step-2 run command (python manage.py makemigrations your app name
Step -3 run command (python manage.py migrate)
If still not working...??
repate above steps but this time also deleted sqlite3 database
Upvotes: 0