error - no such table

I’m trying to make an e-mail authorization and get an error when creating superuser. What’s wrong?

application ‘www’

from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin
from django.db import models
from django.utils import timezone

class UserManager(BaseUserManager):

def _create_user(self, email, password, is_staff, is_superuser, **extra_fields):
if not email:
raise ValueError(‘Users must have an email address’)
now =
email = self.normalize_email(email)
user = self.model(
return user

def create_user(self, email, password, **extra_fields):
return self._create_user(email, password, False, False, **extra_fields)

def create_superuser(self, email, password, **extra_fields):
user=self._create_user(email, password, True, True, **extra_fields)
return user

class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(max_length=254, unique=True)
name = models.CharField(max_length=254, null=True, blank=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
last_login = models.DateTimeField(null=True, blank=True)
date_joined = models.DateTimeField(auto_now_add=True)

EMAIL_FIELD = 'email'

objects = UserManager()

def get_absolute_url(self):
    return "/users/%i/" % (


ROOT_URLCONF = ‘www.urls’

‘NAME’: ‘django.contrib.auth.password_validation.UserAttributeSimilarityValidator’,
‘NAME’: ‘django.contrib.auth.password_validation.MinimumLengthValidator’,
‘NAME’: ‘django.contrib.auth.password_validation.CommonPasswordValidator’,
‘NAME’: ‘django.contrib.auth.password_validation.NumericPasswordValidator’,

AUTH_USER_MODEL = ‘www.User’


(env) isaev@web:~/plg/www$ python createsuperuser
Traceback (most recent call last):
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/”, line 84, in _execute
return self.cursor.execute(sql, params)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/sqlite3/”, line 413, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: www_user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “”, line 22, in
File “”, line 18, in main
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/core/management/”, line 401, in execute_from_command_line
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/core/management/”, line 395, in execute
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/core/management/”, line 330, in run_from_argv
self.execute(*args, **cmd_options)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/contrib/auth/management/commands/”, line 79, in execute
return super().execute(*args, **options)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/core/management/”, line 371, in execute
output = self.handle(*args, options)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/contrib/auth/management/commands/”, line 113, in handle
error_msg = self._validate_username(username, verbose_field_name, database)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/contrib/auth/management/commands/”, line 234, in _validate_username
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/contrib/auth/”, line 45, in get_by_natural_key
return self.get(
{self.model.USERNAME_FIELD: username})
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/models/”, line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/models/”, line 425, in get
num = len(clone)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/models/”, line 269, in len
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/models/”, line 1308, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/models/”, line 53, in iter
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/models/sql/”, line 1156, in execute_sql
cursor.execute(sql, params)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/”, line 98, in execute
return super().execute(sql, params)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/”, line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/”, line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/”, line 84, in _execute
return self.cursor.execute(sql, params)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/”, line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/”, line 84, in _execute
return self.cursor.execute(sql, params)
File “/home/isaev/plg/env/lib/python3.8/site-packages/django/db/backends/sqlite3/”, line 413, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: www_user

1 Like

Did you do a makemigrations followed by a migrate? Did you see the table being created as part of the migrate process? Can you go directly into the database and verify that the table exists?


(env) isaev@web:~/plg/www$ python makemigrations
No changes detected
(env) isaev@web:~/plg/www$ python migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial… OK
Applying admin.0001_initial… OK
Applying admin.0002_logentry_remove_auto_add… OK
Applying admin.0003_logentry_add_action_flag_choices… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0001_initial… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying auth.0007_alter_validators_add_error_messages… OK
Applying auth.0008_alter_user_username_max_length… OK
Applying auth.0009_alter_user_last_name_max_length… OK
Applying auth.0010_alter_group_name_max_length… OK
Applying auth.0011_update_proxy_permissions… OK
Applying auth.0012_alter_user_first_name_max_length… OK
Applying sessions.0001_initial… OK

And I don’t see table ‘www_user’ in my database (

sqlite> .open db.sqlite3
sqlite> .tables
auth_group django_admin_log django_session
auth_group_permissions django_content_type
auth_permission django_migrations

So you can see that you don’t have a migration for app www - the easiest way to fix this is by specifying the app name on your makemigrations command: makemigrations www


You’re a genius. Everything worked ) Thanks a lot

you helped me. thanks

Hi @KenWhitesell ,

I am getting same error on makemigrations call .

getting error as follow
django.db.utils.OperationalError: no such table: app_mynewmodel

And error is throwing from at following point :-

if MyNewModel.objects.filter().exist():

If I remove the code line above, I can see that the migration is successful .It seems like issue with exist() call . Is this expected error ?

This is likely a different problem - please open a new topic to discuss it, along with posting the complete view causing this issue. Also, provide a brief description of what you had done up to this point. (Is this the first makemigrations for this project? Was it working before adding that line of code?)

I also have same problem, makemigration app_name ran successfully but the error still exists
please help me too. I deleted all previous migrations and ran makemigrations and migrate commands again but still the same problem

This is likely a different problem than the ones discussed previously - please open a new topic to discuss it

i have been struggling with the same problem, could you please let me know if you were able to fix this. ‘ makemigrations appname’ did not work for me

This is likely a different problem than the ones discussed previously - please open a new topic to discuss it.
Provide a brief description of your project and what you have done up to this point along with the relevant details of the error you’re encountering. (Is this the first makemigrations for this project? Did it ever work?)