For various complicated reasons[1] I need to add extra properties to the Django User class.
I can't use either Profile nor the "inheritance" way of doing this. (As in http://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django )
So what I've been doing is including the User class in my local_settings file. And adding the property to it there.
This, perhaps surprisingly, seems to work in many cases. But not when I create a new User from UserManager.create_user(). So I need to patch an alternative to the UserManager.create_user() method. Looking at the source for this (in contrib.auth.models.py) I find that the class it uses to create the User is kept in a property called UserManager.model rather than referenced directly.
The line is this :
user = self.model(None, username, '', '', email.strip().lower(), 'placeholder', False, True, False, now, now)
The problem is that this self.model (which I assume contains a reference to the User class) doesn't seem to be my patched version.
So, does anyone know where this self.model is set-up in the case of UserManager? And whether I'm correct in assuming that at that point the code hasn't gone through local_settings so my patch to the User class isn't there? And if there's a better place to patch the class?
cheers
phil
[1] To satisfy the cur ious. I need to make the User class use a different and existing table in the database, which has extra fields and constraints.
Update : For future reference, it looks like Proxy Models are the way that Django's going to support what I need : http://code.djangoproject.com/ticket/10356