Python - Django error when creating super user


I am creating a student management service. Once I finish designing the models I make the migrations (makemigrations and migrate) of my apps, without problems. But when trying to create a super user, this error occurs:

Nombre de usuario: Admin
Dirección de correo electrónico: [email protected]
Password (again): 
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/django/db/backends/",line 85, in _execute
     return self.cursor.execute(sql, params)
  File "/usr/lib/python3.7/site-    packages/django/db/backends/sqlite3/", line 296, in execute
     return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: main.alumnos_materiasalumno__old

I am using django 2.1.4 with sqlite3 in python 3.7. Traceback in pastebin

asked by Seba 24.12.2018 в 18:43

2 answers


The problem is with django 2.1.4 with sqlite3 (3.26), it seems that there is an error already marked link . My solution was simply to use a production database, postgresql in my case and everything works perfect.

The solution, if it is necessary to use sqlite3, is to expect django 2.1.5 to come out in January 2019 ( link ), update the project to the new version and rebuild the sqlite3 database.

answered by 28.12.2018 / 14:46

So it shows the error you share exactly on the following line:

sqlite3.OperationalError: no such table: main.alumnos_materiasalumno__old

There is an error directly with the database, as it says above, it does not find a table ( no such table ), that is, there is no table main.alumnos_materiasalumno__old

By the same token it is certain that you have some error in the migration of the data to the SQLITE Database

Since you are using SQLITE, within the file where the data of the database is to be used, nothing should be moved, since by default it comes with the necessary data to use SQLITE.

# Database

    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

The previous code is how it comes by default.

If everything is correct and the same problem remains, I recommend:

  • Review each of the models you have created, remember that from these the tables are created with their respective relations in the database (more specifically main.alumnos_materiasalumno__old ).
  • Verify that the migrations touch all the apps that you have in the system and models

On the other hand, when I have had some type of error related to the DB, I have simply deleted it completely to be able to migrate again and I always do the following:

  • Delete the SQLITE file , inside the main folder of the project there is a file called db.slite3 , which I delete.
  • Delete all the files in the migration folder, everything except the file, found in each of the apps you created
  • Execute the command python makemigrations , for migrations of your data
  • And finally start the command python migrate
  • You tell me how you're doing:)

    answered by 24.12.2018 в 22:18