diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py
index f052c45..1ae7ed8 100644
--- a/djangocms_blog/models.py
+++ b/djangocms_blog/models.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from cms.models import PlaceholderField, CMSPlugin
from cmsplugin_filer_image.models import ThumbnailOption
-from django.contrib.auth.models import User
+from django.conf import settings as dj_settings
from django.core.urlresolvers import reverse
from django.db import models
from django.utils import timezone
@@ -62,7 +62,8 @@ class Post(ModelMeta, TranslatableModel):
"""
Blog post
"""
- author = models.ForeignKey(User, verbose_name=_('Author'), null=True, blank=True,
+ author = models.ForeignKey(dj_settings.AUTH_USER_MODEL,
+ verbose_name=_('Author'), null=True, blank=True,
related_name='djangocms_blog_post_author')
date_created = models.DateTimeField(auto_now_add=True)
@@ -217,11 +218,14 @@ class LatestPostsPlugin(CMSPlugin):
class AuthorEntriesPlugin(CMSPlugin):
- authors = models.ManyToManyField(User, verbose_name=_('Authors'),
- limit_choices_to={'djangocms_blog_post_author__publish': True}
- )
- latest_posts = models.IntegerField(_(u'Articles'), default=settings.BLOG_LATEST_POSTS,
- help_text=_('The number of author articles to be displayed.'))
+ authors = models.ManyToManyField(
+ dj_settings.AUTH_USER_MODEL, verbose_name=_('Authors'),
+ limit_choices_to={'djangocms_blog_post_author__publish': True}
+ )
+ latest_posts = models.IntegerField(
+ _(u'Articles'), default=settings.BLOG_LATEST_POSTS,
+ help_text=_('The number of author articles to be displayed.')
+ )
def __unicode__(self):
return u"%s latest articles by author" % self.latest_posts
diff --git a/djangocms_blog/templates/djangocms_blog/includes/blog_item.html b/djangocms_blog/templates/djangocms_blog/includes/blog_item.html
index f7884d0..f5c2022 100644
--- a/djangocms_blog/templates/djangocms_blog/includes/blog_item.html
+++ b/djangocms_blog/templates/djangocms_blog/includes/blog_item.html
@@ -7,7 +7,7 @@
{% block blog_meta %}
-
- {% trans "by" %} {{ post.author.get_full_name }}
+ {% trans "by" %} {{ post.author.get_full_name }}
-
{{ post.date_published|date:"M d, Y" }}
diff --git a/djangocms_blog/templates/djangocms_blog/plugins/authors.html b/djangocms_blog/templates/djangocms_blog/plugins/authors.html
index 9669eb6..759f494 100644
--- a/djangocms_blog/templates/djangocms_blog/plugins/authors.html
+++ b/djangocms_blog/templates/djangocms_blog/plugins/authors.html
@@ -3,7 +3,7 @@
{% trans "Authors" %}
{% for author in instance.get_authors %}
- -
+
-
{{ author.get_full_name }}
(
{% if author.count > 0 %}
diff --git a/djangocms_blog/templates/djangocms_blog/post_detail.html b/djangocms_blog/templates/djangocms_blog/post_detail.html
index 7d151f3..e283417 100644
--- a/djangocms_blog/templates/djangocms_blog/post_detail.html
+++ b/djangocms_blog/templates/djangocms_blog/post_detail.html
@@ -13,7 +13,7 @@
{% block blog_meta %}
-
- {% trans "by" %} {{ post.author.get_full_name }}
+ {% trans "by" %} {{ post.author.get_full_name }}
-
{{ post.date_published|date:"M d, Y" }}
diff --git a/djangocms_blog/views.py b/djangocms_blog/views.py
index b8dd8e7..f354a21 100644
--- a/djangocms_blog/views.py
+++ b/djangocms_blog/views.py
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
-from django.utils.translation import get_language
-from django.utils.timezone import now
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
+from django.conf import settings as dj_settings
from django.core.urlresolvers import resolve
+from django.utils.timezone import now
+from django.utils.translation import get_language
from django.views.generic import ListView, DetailView
from parler.views import ViewUrlMixin, TranslatableSlugMixin
@@ -11,6 +12,8 @@ from .models import Post, BlogCategory, BLOG_CURRENT_POST_IDENTIFIER
from .settings import (BLOG_PAGINATION, BLOG_POSTS_LIST_TRUNCWORDS_COUNT,
BLOG_USE_PLACEHOLDER)
+User = get_user_model()
+
class BaseBlogView(ViewUrlMixin):
@@ -107,11 +110,11 @@ class AuthorEntriesView(BaseBlogView, ListView):
def get_queryset(self):
qs = super(AuthorEntriesView, self).get_queryset()
if 'username' in self.kwargs:
- qs = qs.filter(author__username=self.kwargs['username'])
+ qs = qs.filter(**{'author__%s' % User.USERNAME_FIELD: self.kwargs['username']})
return qs
def get_context_data(self, **kwargs):
- kwargs['author'] = User.objects.get(username=self.kwargs.get('username'))
+ kwargs['author'] = User.objects.get(**{User.USERNAME_FIELD: self.kwargs.get('username')})
return super(AuthorEntriesView, self).get_context_data(**kwargs)