Commits

Robert Osborne committed 5ac448b

support for Django 1.5.1 Custom User models

  • Participants
  • Parent commits a21144d

Comments (0)

Files changed (4)

articles/admin.py

 import logging
 
 from django.contrib import admin
-from django.contrib.auth.models import User
 from django.utils.translation import ugettext_lazy as _
 from forms import ArticleAdminForm
 from models import Tag, Article, ArticleStatus, Attachment
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
 
 log = logging.getLogger('articles.admin')
 

articles/management/commands/check_for_articles_from_email.py

 import time
 
 from django.conf import settings
-from django.contrib.auth.models import User
 from django.contrib.sites.models import Site
 from django.core.management.base import BaseCommand
 from django.utils.translation import ugettext_lazy as _
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
 
 from articles.models import Article, Attachment, MARKUP_HTML, MARKUP_MARKDOWN, MARKUP_REST, MARKUP_TEXTILE
 

articles/models.py

 
 from django.db import models
 from django.db.models import Q
-from django.contrib.auth.models import User
 from django.contrib.markup.templatetags import markup
 from django.contrib.sites.models import Site
 from django.core.cache import cache
 from django.utils.translation import ugettext_lazy as _
 from django.utils.text import truncate_html_words
 
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
+
 from decorators import logtime, once_per_instance
 
 WORD_LIMIT = getattr(settings, 'ARTICLES_TEASER_LIMIT', 75)

articles/views.py

 import logging
 
 from django.conf import settings
-from django.contrib.auth.models import User
 from django.core.cache import cache
 from django.core.paginator import Paginator, EmptyPage
 from django.core.urlresolvers import reverse
 from django.template import RequestContext
 from articles.models import Article, Tag
 from datetime import datetime
+try:
+    from django.contrib.auth import get_user_model
+    User = get_user_model()
+except ImportError:
+    from django.contrib.auth.models import User
 
 ARTICLE_PAGINATION = getattr(settings, 'ARTICLE_PAGINATION', 20)