Skip to content
Advertisement

“OperationalError: no such table: django_site” when running makemigrations with empty database when using Django-todo

I have inherited a Django 1.11.6 application from another developer. Now after I have made a lot of changes to the code and data model, I want to re-create the sqlite database from scratch.

But when I run manage.py makemigrations in the project directory (no migration files and database present), I am getting the following error message:

JavaScript

'django.contrib.sites' is present in the INSTALLED_APPS and there is a SITE_ID defined. Every solution I found on stackoverflow and other sources didn’t fix the problem.

How can I get past this and continue developing the application with a empty database?

Advertisement

Answer

The traceback shows that todoutils.py is trying to fetch the current site from the database when the URL patterns are loaded:

JavaScript

When this happens before you have run migrate for the first time, you get the error because the django_site table has not been created yet.

It looks as if the issue has been fixed in django-todo 2.0. If you can’t upgrade, then as a hack you could temporarily comment out the django-todo urls.py or the current_site = Site.objects.get_current() line, so that you can run migrate.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement