DEV Community

sium_hossain
sium_hossain

Posted on

18 2

#Solved - ValueError: The field admin.LogEntry.user was declared with a lazy reference.

Here is the error happened when we want to try Abstract User model in the middle of the project

Here is the Error look like πŸ‘

ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'core.user', but app 'core' doesn't provide model 'user'.
Enter fullscreen mode Exit fullscreen mode

We have to remove all migrations from our project by

find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
Enter fullscreen mode Exit fullscreen mode
find . -path "*/migrations/*.pyc"  -delete
Enter fullscreen mode Exit fullscreen mode

Then delete the database.Then run migrations & migrate again.

python manage.py makemigrations 
python manage.py migrate
Enter fullscreen mode Exit fullscreen mode

πŸ‘Š Voila problem Solved..

Top comments (6)

Collapse
 
sfarpak profile image
SFARPak β€’

To delete migrations with ease I have created a Script you may use here
github.com/SFARPak/Python-Django-D...

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli β€’

Super helpful, thank you!

Collapse
 
siumhossain profile image
sium_hossain β€’

My pleasure πŸ’•

Collapse
 
andresfelipecs profile image
Felipe Castro β€’

Thank you ! It solved the issues I had πŸ‘πŸΌπŸ™πŸ½

Collapse
 
pranith7 profile image
Pranith Pashikanti β€’

what if i dont want to delete the database

Collapse
 
sfarpak profile image
SFARPak β€’

I also got following error using your script:

FIND: Parameter format not correct

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more