Aiky30 / djangocms-4-migration

BSD 3-Clause "New" or "Revised" License
5 stars 13 forks source link

Custom user model support #15

Open radiac opened 6 months ago

radiac commented 6 months ago

The documented CMS_MIGRATION_USER_ID doesn't seem to be in use at the moment. My guess is that it's intended for use in helpers.get_or_create_migration_user, which doesn't currently work with User models that are missing the username field?

Rather than implementing it by user ID, would it be worth having a dict-based setting which can be passed to get_or_create, so for example if my user model has an email-based login, I could set CMS_MIGRATION_USER={"email": "djangocms_4_migration_user@example.com"}

rvanlaar commented 4 months ago

I found a related issue in 0003_page_version_integration_data_migration.py

The user model is defined as User = apps.get_model(*settings.AUTH_USER_MODEL.split('.')) This result in a

(Pdb) apps.get_model(*settings.AUTH_USER_MODEL.split('.'))
<class '__fake__.User'>

Recommended is to use get_user_model() per: https://docs.djangoproject.com/en/5.0/topics/auth/customizing/#referencing-the-user-model As is also done in the function get_or_create_migration_user.

(Pdb) from django.contrib.auth import get_user_model
(Pdb) get_user_model()
<class 'edubroker_kom.edubroker.models.edubrokeraccounts.User'>