I've been thinking about external app compatibility as well and it seems like:
from django.conf import settings
AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
class SomeModel(models.Model):
author = models.ForeignKey(AUTH_USER_MODEL)
is the easiest solution to me.
Best,
Mark
On Friday, September 28, 2012 8:14:57 AM UTC-4, rizumu wrote:
>
>
> It is great to see this merged, it has been a long time coming. :)
>
> I would like to add backwards compatibility to some apps and I'm looking
> for a recommended technique. Could the following, or a better option, find
> its way into the docs in a section specific to app developers tasked with
> adding support for auth_user_model. Having a recommendation in the docs
> would make pull requests with this feature more likely and easier to handle.
>
>
> try:
> from django.contrib.auth import get_user_model
> auth_user_model = get_user_model()
> except ImportError:
> from django.contrib.auth.models import User
> auth_user_model = User
>
> class SomeModel(models.Model):
>
> author = models.ForeignKey(auth_user_model)
>
> Because this isn't backwards compatible:
>
> class SomeModel(models.Model):
>
> author = models.ForeignKey(settings.AUTH_USER_MODEL)
>
> best,
> Tom
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-developers/-/NukaEX99YXQJ.
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.