Closed kevinetienne closed 9 years ago
Having such a long chain of inheritance is maybe not the best solution, dealing with python mro and Django Meta
class has proven not to be easy to use.
One of the downside of what I have created is that one should reimplement the Thanks @Ian-Foote check
s when customising VerifyEmailMixin
.
@Ian-Foote @meshy could you have a look to this PR please?
Just to clarify: it's not possible to just subclass the parent, and re-define the fields?
@meshy unfortunately no :( The error message is the following: django.core.exceptions.FieldError: Local field 'name' in class 'User' clashes with field of similar name from base class 'VerifyEmailMixin'
and then you try to subclass VerifyEmailMixin
but same error :)
it might be related to the Meta
class generating something from the attributes on the class.
Aaah, I guess it is. Shame. Ok then :)
Relevant piece of code: https://github.com/django/django/blob/d66bda60590daabe21f60a532a613a31a10fedbd/django/db/models/base.py#L229-L238 (might be fixed in the future)
@Ian-Foote @mattack108 can you merge please?
Customising fields on
BasicUserFieldsMixin
is not easy. I have a case where I need to overridename
andemail
.My use case:
With the current implementation the solution is to copy
VerifyEmailMixin
and its parent classBasicUserFieldsMixin
to redefinename
andemail
fields to avoid name clashes.It looks like splitting the current mixins to more mixins will allow redefining fields more easily. I suggest to make
BasicUserFieldsMixin
andVerifyEmailMixin
children classes of some fields and methods.Example:
Which would allow us to create own
BasicUserFieldsMixin
andVerifyEmailMixin
if one or more fields need changing.