Django.db.utils.OperationalError: no such table: django_site_id_seq

I got this error when running command python test for testing purpose. I tried after delete my pycache and migration files and db.sqlite3 then run the python makemigrations and python migrate again as well.

But still got the same error...

Here is my

from rest_framework.test import APITestCase
from django.urls import reverse
from rest_framework import status

# Create your tests here.

class UserTest(APITestCase):

    def setUp(self):
        register_url = reverse('user:register')
        data = {
        }, data, format='json')

    def test_user_can_register(self):
        register_url = reverse('user:register')
        data = {
        response = , data , format='json')
        self.assertEqual(response.status_code ,status.HTTP_201_CREATED)

Have you added your app in to installed apps?

In hour installed app comment out django sites. Do makemigrations and migrate. Then reactivate django sites and do the migration stuff again

Try switching to postgresql, to see if it is a database issue always good to try something else. if that doesn’t work then I would get an existing example that does work and compare it from there to what you have. tbh unless you have your code opensource it is difficult to debug something like this without speculation as a lot of different systems are affected when ensuring migrations are applied. Check your migrations files to see if those are indeed correct. they should be under /migrations

Back to Top