0

I am new to Django and web development in general. I am trying to test my app, recipe_book, using the admin page.

When try to login at http://127.0.0.1:8000/admin, I get the following error:

no such table: recipe_book_user

I have a model class named "User", defined below:

from django.contrib.auth.models import AbstractUser

class User(AbstractUser):
    pass

I then successfully made migrations and migrated the changes.

To resolve this issue, I've tried registering the User class in admin.py, with no success. I've also tried following the steps to reset the database in the following question:

Django - no such table exception

Does anyone know how I can resolve this?

spheroidic
  • 199
  • 7
  • Does your user model appear in the migration files that you generate and migrate? – 0sVoid Aug 07 '22 at 21:03
  • I looked at the database in sqlite3 and I don't see any tables for the models I created. Although I do see some called "auth_group" and so on. So I guess it did not migrate correctly. Do you know if there are other files I could check? – spheroidic Aug 07 '22 at 21:08
  • You can look at the actual migration files that Django creates in your app's `migrations` folder, they will be the same as the console, e.g. `0001_auto_blah_blah.py` – 0sVoid Aug 07 '22 at 21:10
  • Hm I actually don't see a migrations folder! Just `__pycache__` and the templates folder I created. – spheroidic Aug 07 '22 at 21:18
  • Did you put your app name in your settings.py `INSTALLED_APPS` list? – 0sVoid Aug 07 '22 at 21:19
  • I did, yes. Under `'django.contrib.staticfiles'` – spheroidic Aug 07 '22 at 21:22
  • Rather odd, try manually adding a `migrations` folder with an `__init__.py` file within and then re-run makemgirations and migrate – 0sVoid Aug 07 '22 at 21:24
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/247107/discussion-between-spheroidic-and-0svoid). – spheroidic Aug 07 '22 at 21:31

1 Answers1

0

I resolved this - it turns out that my migrations weren't being created. I had been typing python manage.py makemigrations instead of python manage.py [app_name] in my initial migration. Problem solved!

spheroidic
  • 199
  • 7