Skip to content

Instantly share code, notes, and snippets.

@theskumar
Created June 14, 2014 05:35
Show Gist options
  • Save theskumar/ff8de60ff6a33bdacaa8 to your computer and use it in GitHub Desktop.
Save theskumar/ff8de60ff6a33bdacaa8 to your computer and use it in GitHub Desktop.
Django Compatibility
import django
from django.conf import settings
from django.utils import six
# Django 1.5 add support for custom auth user model
if django.VERSION >= (1, 5):
AUTH_USER_MODEL = settings.AUTH_USER_MODEL
else:
AUTH_USER_MODEL = "auth.User"
try:
from django.contrib.auth import get_user_model
except ImportError:
from django.contrib.auth.models import User
get_user_model = lambda: User
# get_indent
if six.PY3:
from threading import get_ident
else:
from thread import get_ident # noqa
@philippeowagner
Copy link

Hi
We created an app called django-compat to handle exactly these challenges. Eventually you can use it at some time in your projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment