I wanted to add some more fields to Django's default User model I imported AbstractUser and inherit it in my User class and added my app to INSTALLED_APPS and added this line in settings.py AUTH_USER_MODEL='music.User' in which music is my app's name and User is my model name but in migration, i got this error: ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'music.user', but app 'music' doesn't provide model 'user'. what should I do?
Asked
Active
Viewed 104 times
1
-
1Please show some code so we can help. – Dream_Cap Feb 25 '18 at 10:16
-
It's either you missed the case of your models(it's case sensitive), your `music` is wrong, your migrations are messed up, since you it's not that easy to change auth user model if you already have db. And yes, code will help. – vishes_shell Feb 25 '18 at 11:33
-
It was because had an user instance already I think with starting a fresh project the problem was solved – Mahdi Sorkhmiri Feb 25 '18 at 13:42
-
you need to delete all of your migration files in relation with the user model since using custom user must be created in the first migration – Shift 'n Tab Feb 25 '18 at 13:47
-
@RoelDelosReyes how should I do that? If I just delete the migration files I will have much more errors – Mahdi Sorkhmiri Feb 25 '18 at 13:52
-
This application is messed up if you are shifting from built in user to custom user in your mid-late development, creating custom user must be created in the first migration of your application to avoid complicated things like this. In order to do that you have to delete your migration files and the database also and remigrate again. but be sure to have some backup. – Shift 'n Tab Feb 25 '18 at 14:03
-
This might help you https://docs.djangoproject.com/en/2.0/topics/auth/customizing/#changing-to-a-custom-user-model-mid-project – Shift 'n Tab Feb 25 '18 at 14:06
-
@RoelDelosReyes thanks a lot – Mahdi Sorkhmiri Feb 25 '18 at 14:26