I have the same conundrum as presented in this question, but applied to Django's auth.User.
I have this proxy model:
class OrderedUser(User):
def __unicode__(self):
return self.get_full_name()
class Meta:
proxy=True
ordering=["first_name", "last_name"]
And some of my other models use an OrderedUser
instead of a django.contrib.auth.models.User
as field types.
In my views I then use the request.user
to populate a field and - as expected - get an error:
'Cannot assign "<User...>": <field> must be a "OrderedUser" instance'
I could just do OrderedUser.objects.get(request.user.id)
, but that is an extra hit to the database.
So, how to convert a base model class into its proxied class?