So, I went ahead and implemented the most useful mixin of the three that I defined previously, the PermissionsMixin. You can see it at https://github.com/ogier/django/blob/permissions-mixin/django/contrib/auth/models.py#L293
This should dramatically simplify the creation of a custom User model in the case that you are OK with Django's default permissions model (and I think many people are). Now instead of reimplementing dumbed-down versions of the permissions code whenever you want to use admin, you can just add PermissionsMixin to your parent classes and *poof* your user model is compatible with contrib.admin (though you still need to roll your own admin class, maybe we can help here too). This would DRY up some of https://docs.djangoproject.com/en/1.5/topics/auth/#a-full-example which could forget about permission-handling code, and still have fully-fledged app permissions. I think this covers 80% of what is missing from the current class hierarchy. Forcing every AbstractBaseUser to have a password isn't strictly required, but seeing as Django's implementation is pretty good and we don't want to encourage people to go rolling their own, it seems like an OK limitation. Forms will still have to be overridden, but that was always inevitable. On Tue, Nov 6, 2012 at 5:02 PM, Anssi Kääriäinen <[email protected]>wrote: > On 6 marras, 23:05, Alex Ogier <[email protected]> wrote: > <SNIP> > > ... Since you can't actually override or change the fields of an > abstract model anyways (so far as I know?) > > Allowing override of abstract parent's fields is fairly trivial > (https://github.com/akaariai/django/compare/abstract_overrides). > > I don't immediately see a reason to disallow override of abstract > parent's fields. > > Anyways it seems there is some room for improvement in model > validation for abstract parent case: > > class Foo(models.Model): > username = models.CharField(max_length=100) > > class Meta: > abstract = True > > class FooOverride(models.Model): > username = models.CharField(max_length=200) > > class Meta: > abstract = True > > class Bar(Foo, FooOverride): > pass > > print(Bar._meta.fields) > [<django.db.models.fields.AutoField: id>, > <django.db.models.fields.CharField: username>, > <django.db.models.fields.CharField: username>] > > - Anssi > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/django-developers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
