lazy reference: doesn't provide model user?

后端 未结 9 1380
独厮守ぢ
独厮守ぢ 2020-12-15 06:33

Currently I\'m using Django 1.11 and Python 3.6. I\'m attempting to create a custom user model with a new application that authenticates with LDAP, but i\'m greeted with th

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 07:13

    For me helped split on two migration

    1. create new table (without connection between new and old tables and without AUTH_USER_MODEL = 'accounts.User')
    2. add AUTH_USER_MODEL to settings.py and other connections with new table

    But it works for dev/production databases if you want to apply migrations from first in tests or another from scratch database creations you should "compact your migrations", for me it was next steps:

    1. Make a dump of a database (in my case by sqldump)
    2. Cleanup database (especially table django_migrations)
    3. Remove all migrations in your project
    4. Run manage.py makemigrations
    5. Add migration that adds all data inserts from your old migrations
    6. Run manage.py migrate
    7. Remove table django_migrations in your dump (maybe some other django_* tables )
    8. Restore your database from a dump

提交回复
热议问题