[Django]-Django 'No such table:" for custom user profile, why?

2👍

Gahh, the answer was that I had commented out my main app’s entry from INSTALLED_APPS. Which is silly.

👤crobar

4👍

First of all, if it worked before, I can’t explain why it no longer is.
You should inspect the sqlite file itself, and see if the table is there. (The file is usually found at the root as db.sqlite3, and can be opened with any standard sqlite browser)

You mentioned you’ve been running migrate, but is the actual migration there already?

Run python manage.py makemigrations first if you haven’t. If need be, verify the migration file itself.

There’s also the python manage.py inspectdb command that could give you some insight to the models you’re using.

If still nothing, you could of course start from scratch. I’ve probably missed a shortcut somewhere, but I’d:

  1. Create a copy of data you do need to keep
    (python manage.py dumpdata --indent=4 <appname>) (Save this into fixtures)
  2. delete migrations files
  3. delete db.sqlite3
  4. run python manage.py makemigrations
  5. run python manage.py migrate
  6. use python manage.py loaddata <fixture-name> to reload old data

3👍

I had the same problem but for me the solution was different. I had accidentally deleted the init.py in the migrations directory while cleaning which meant that some migrations were not running producing the same error. Replacing it solved the issue.

1👍

I had the same issue. To fix it I exit out of the server by Control+C. Than migrate by running these two commands: $ python manage.py makemigrations
it tells me
Migrations for ‘profiles’:

profiles/migrations/0001_initial.py

- Create model profile

than I run $ python manage.py migrate

it tells me

Operations to perform: Apply all migrations: admin, auth,
contenttypes, profiles, sessions Running migrations:

Applying profiles.0001_initial… OK

now I run the server again $ python manage.py runserver

and when I create the profile it shows

[24/Aug/2018 19:36:16] “GET /admin/profiles/profile/add/ HTTP/1.1” 200
4381

[24/Aug/2018 19:36:19] “POST /admin/profiles/profile/add/ HTTP/1.1”
302 0

[24/Aug/2018 19:36:19] “GET /admin/profiles/profile/ HTTP/1.1” 200
4376

[24/Aug/2018 19:36:19] “GET /admin/jsi18n/ HTTP/1.1” 200 3217

[24/Aug/2018 19:36:19] “GET /static/admin/css/changelists.css
HTTP/1.1” 200 6170

[24/Aug/2018 19:36:19] “GET /static/admin/img/tooltag-add.svg
HTTP/1.1” 200 331

[24/Aug/2018 19:36:19] “GET /static/admin/img/icon-yes.svg HTTP/1.1”
200 436

and profile is created. Hope that help.

1👍

Okay its looks like you forget to run the migrations command; just go ahead and run the following command; in the Django shell:

$ python manage.py migrate

Then,

$ python manage.py makemigrations

1👍

$ python manage.py migrate –run-syncdb

that’s the good way try it

Leave a comment