mirror of
https://github.com/jazzband/django-authority.git
synced 2026-04-15 04:21:15 +00:00
20 lines
No EOL
575 B
Python
20 lines
No EOL
575 B
Python
import django
|
|
from django.conf import settings
|
|
from django.contrib import auth
|
|
|
|
|
|
def get_user_class():
|
|
"""
|
|
Returns the User model class. In Django 1.7 and above, get_user_model()
|
|
internally uses the App Registry, which may not be queried until it is ready.
|
|
We can break this cycle via indirection by returning a string instead.
|
|
"""
|
|
if django.VERSION[:2] >= (1, 7):
|
|
return settings.AUTH_USER_MODEL
|
|
elif hasattr(auth, "get_user_model"):
|
|
return auth.get_user_model()
|
|
else:
|
|
return auth.models.User
|
|
|
|
|
|
User = get_user_class() |