UserManager migration error: no attribute 'polymorphic_primary_key_name' #810
-
|
I have custom user db model Helpdesk app Call this code line |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I know this is quite old but I just tried to do a similar thing with a polymorphic Profile model and a custom user model that inherits from Profile (i.e. the same as described above). After getting the same error and seeing no solution to this issue, I decided to do a little digging. Turns out, Django doesn't strictly use the models from your Thankfully, there is a quick and easy fix for this issue: in you custom manager on the User model, make sure the attribute E.g. If you rely on the polymorphic manager in your own migration files for some reason and therefore can't set use_in_migrations to False, you will need to contact the author of the offending migration file and ask them to properly import the user model via django's Hope this helps someone. |
Beta Was this translation helpful? Give feedback.
I know this is quite old but I just tried to do a similar thing with a polymorphic Profile model and a custom user model that inherits from Profile (i.e. the same as described above). After getting the same error and seeing no solution to this issue, I decided to do a little digging.
Turns out, Django doesn't strictly use the models from your
models.pyfiles during migrations. I discovered this by placing aprint(type(User))statement in the offending migration file which returned<class '__fake__.User'>. Therefore the fake model did not use the polymorphic metaclass and therefore did not have the required attribute above.Thankfully, there is a quick and easy fix for this issue: in you c…