2

I have been using django for many years but have not seen such issue before.

I am working on an old/legacy project. And I am originally facing this issue. So as the solution suggest, I run auth migrations first,

$python manage.py migrate auth
Operations to perform:
Apply all migrations: auth
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... 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

But when I check my mysql database, only django_migrations table gets created. I don't see auth_user, auth_group, auth_permissions, etc.

$python manage.py showmigrations auth
auth
 [X] 0001_initial
 [X] 0002_alter_permission_name_max_length
 [X] 0003_alter_user_email_max_length
 [X] 0004_alter_user_username_opts
 [X] 0005_alter_user_last_login_null
 [X] 0006_require_contenttypes_0002
 [X] 0007_alter_validators_add_error_messages
 [X] 0008_alter_user_username_max_length

mysql> show tables;
django_migrations

I am using Python3.6 and Django==1.11.5. My INSTALLED_APPS looks like this,

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'debug_toolbar',
    'djcelery',
    'widget_tweaks',
    'djangosaml2',

    # ... more apps from my project
]

What could be wrong? Has anyone come across such issue.

Hussain
  • 5,057
  • 6
  • 45
  • 71
  • Have a look at those two commands: https://docs.djangoproject.com/en/1.11/ref/django-admin/#showmigrations and https://docs.djangoproject.com/en/1.11/ref/django-admin/#sqlmigrate just to check if the migrations are ok – Karim N Gorjux Sep 07 '18 at 07:23
  • I just updated my post. – Hussain Sep 07 '18 at 07:29
  • @Hussain does the `showmigrations` command returns `[X]` ? or `[ ]` ? – JPG Sep 07 '18 at 07:30
  • It shows [X] @JPG – Hussain Sep 07 '18 at 07:31
  • Is it possible to log-in to Django Admin? – JPG Sep 07 '18 at 07:38
  • No. "Table 'mydb.auth_user' doesn't exist") – Hussain Sep 07 '18 at 07:41
  • Are you sure you have your database settings configured corretly? Use `python manage.py dbshell` and then run `SHOW TABLES;` – BBT Sep 08 '18 at 11:22
  • Same result. Don't see `auth_` tables. I only see `django_migrations` table. And when I `select * from django_migrations` it shows all `auth` and `contenttypes` migrations applied. So weird. – Hussain Sep 10 '18 at 02:12
  • Same here. Because it looks like Django has not migrated all tables, I cannot login into admin dashboard. It prints out `relation "auth_user" does not exist` – Matej J Jul 16 '20 at 07:42

0 Answers0