Django admin and SQLite: database disk image is malformed

EvilSmurf picture EvilSmurf · Sep 22, 2014 · Viewed 8.3k times · Source

I have developed a Django powered web-pages where I am storing pretty much all content inside a database, let's say sqlite.db

Django properly reads all information from the database and displays the webpage correctly.

Using the admin interface however (on the production server -> the development server coming with the pydev plugin from Eclipse is working fine) the database cannot be accessed. If I just copy the database file it tells me it cannot read and I don't even get the log-on screen to the admin app of django. If I change the file and directory permissions as suggested in many forums I am getting the admin login screen, however django returns the "DatabaseError at /admin/ - database disk image is malformed" Error.

I am using Django 1.6.5 and sqlite3 3.7.13

Any ideas?

EDIT: I found out that only the main page of the django admin interface is affected. I can navigate to the app settings with no problems.

Answer

vikas thakur picture vikas thakur · Sep 3, 2019

Only three steps.

  1. delete db.sqlite3 and all migrations files
  2. run python manage.py makemigrations
  3. run python manage.py migrate