On Sun, Sep 16, 2012 at 1:07 AM, Anssi Kääriäinen <anssi.kaariai...@thl.fi> wrote: > On 15 syys, 18:59, Anssi Kääriäinen <anssi.kaariai...@thl.fi> wrote: >> With the above commits I can do this: >> >> class MyUser(AbstractUser): >> employee_no = models.CharField(max_length=5) >> some_other_field = models.TextField(null=True, blank=True) >> REQUIRED_FIELDS = AbstractUser.REQUIRED_FIELDS + ['employee_no'] >> >> syncb & create_superuser commands work. Admin doesn't work directly, >> but it seems you can easily subclass the default user admin & change >> form to make it work. >> >> Single-table inheritance seems useful to me, and the added complexity >> to code isn't much. > > Actually, there is more common use case which doesn't seem to be > solved by the current branch: getting proxy instances into > request.user. If you use just ProxyUser(auth.User) the proxy model > will not be loaded into request.user, and if you set the ProxyUser as > AUTH_USER_MODEL, then it will not work as you can't subclass the > swapped out auth.User. > > The added commits solves this by allowing you to do: > class MyUser(AbstractUser): > # define additional methods etc. > and: > settings.AUTH_USER_MODEL = 'myuser' > > This could also be solved by somehow allowing fetching proxy instance > to request.user. In any case, IMO this needs some solution before > release.
I'm not sure there can be *any* clean answer for this. A base class can't be swapped out at time of class construction, so I'm not sure how we would handle proxied User models in any meaningful way. My inclination here is to raise an error if, during class construction, the base class of a proxy class is found to be swapped, and document this as a known limitation. Russ %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.