"""Author model for Zinnia"""
from django.db import models
from django.contrib.auth import get_user_model
from django.utils.encoding import python_2_unicode_compatible

from zinnia.managers import entries_published
from zinnia.managers import EntryRelatedPublishedManager


@python_2_unicode_compatible
class Author(get_user_model()):
    """
    Proxy model around :class:`django.contrib.auth.models.get_user_model`.
    """

    objects = get_user_model()._default_manager
    published = EntryRelatedPublishedManager()

    def entries_published(self):
        """
        Returns author's published entries.
        """
        return entries_published(self.entries)

    @models.permalink
    def get_absolute_url(self):
        """
        Builds and returns the author's URL based on his username.
        """
        return ('zinnia_author_detail', [self.get_username()])

    def __str__(self):
        """
        If the user has a full name, use it instead of the username.
        """
        return self.get_full_name() or self.get_username()

    class Meta:
        """
        Author's meta informations.
        """
        app_label = 'zinnia'
        proxy = True

"""Author model for Zinnia"""
from django.db import models
from django.contrib.auth import get_user_model
from django.utils.encoding import python_2_unicode_compatible

from zinnia.managers import entries_published
from zinnia.managers import EntryRelatedPublishedManager

class AuthorManagers(models.Model):
    published = EntryRelatedPublishedManager()

    class Meta:
        abstract = True

@python_2_unicode_compatible
class Author(get_user_model(), AuthorManagers):
    """
    Proxy model around :class:`django.contrib.auth.models.get_user_model`.
    """

    def entries_published(self):
        """
        Returns author's published entries.
        """
        return entries_published(self.entries)

    @models.permalink
    def get_absolute_url(self):
        """
        Builds and returns the author's URL based on his username.
        """
        return ('zinnia_author_detail', [self.get_username()])

    def __str__(self):
        """
        If the user has a full name, use it instead of the username.
        """
        return self.get_full_name() or self.get_username()

    class Meta:
        """
        Author's meta informations.
        """
        app_label = 'zinnia'
        proxy = True

Move Author Managers into an abstract base class
Move Author Managers into an abstract base class

Copying of the default manager causes the source model to become poluted.
To supply additional managers without replacing the default manager,
the Django docs recommend inheriting from an abstract base class.

https://docs.djangoproject.com/en/dev/topics/db/models/#proxy-model-managers

  """Author model for Zinnia"""
  from django.db import models
  from django.contrib.auth import get_user_model
  from django.utils.encoding import python_2_unicode_compatible
  
  from zinnia.managers import entries_published
  from zinnia.managers import EntryRelatedPublishedManager
  
+ class AuthorManagers(models.Model):
+     published = EntryRelatedPublishedManager()
+ 
+     class Meta:
+         abstract = True
  
  @python_2_unicode_compatible
- class Author(get_user_model()):
+ class Author(get_user_model(), AuthorManagers):
      """
      Proxy model around :class:`django.contrib.auth.models.get_user_model`.
      """
- 
-     objects = get_user_model()._default_manager
-     published = EntryRelatedPublishedManager()
  
      def entries_published(self):
          """
          Returns author's published entries.
          """
          return entries_published(self.entries)
  
      @models.permalink
      def get_absolute_url(self):
          """
          Builds and returns the author's URL based on his username.
          """
          return ('zinnia_author_detail', [self.get_username()])
  
      def __str__(self):
          """
          If the user has a full name, use it instead of the username.
          """
          return self.get_full_name() or self.get_username()
  
      class Meta:
          """
          Author's meta informations.
          """
          app_label = 'zinnia'
          proxy = True
  
Move Author Managers into an abstract base class
## Code Before:
"""Author model for Zinnia"""
from django.db import models
from django.contrib.auth import get_user_model
from django.utils.encoding import python_2_unicode_compatible

from zinnia.managers import entries_published
from zinnia.managers import EntryRelatedPublishedManager


@python_2_unicode_compatible
class Author(get_user_model()):
    """
    Proxy model around :class:`django.contrib.auth.models.get_user_model`.
    """

    objects = get_user_model()._default_manager
    published = EntryRelatedPublishedManager()

    def entries_published(self):
        """
        Returns author's published entries.
        """
        return entries_published(self.entries)

    @models.permalink
    def get_absolute_url(self):
        """
        Builds and returns the author's URL based on his username.
        """
        return ('zinnia_author_detail', [self.get_username()])

    def __str__(self):
        """
        If the user has a full name, use it instead of the username.
        """
        return self.get_full_name() or self.get_username()

    class Meta:
        """
        Author's meta informations.
        """
        app_label = 'zinnia'
        proxy = True

## Instruction:
Move Author Managers into an abstract base class
## Code After:
"""Author model for Zinnia"""
from django.db import models
from django.contrib.auth import get_user_model
from django.utils.encoding import python_2_unicode_compatible

from zinnia.managers import entries_published
from zinnia.managers import EntryRelatedPublishedManager

class AuthorManagers(models.Model):
    published = EntryRelatedPublishedManager()

    class Meta:
        abstract = True

@python_2_unicode_compatible
class Author(get_user_model(), AuthorManagers):
    """
    Proxy model around :class:`django.contrib.auth.models.get_user_model`.
    """

    def entries_published(self):
        """
        Returns author's published entries.
        """
        return entries_published(self.entries)

    @models.permalink
    def get_absolute_url(self):
        """
        Builds and returns the author's URL based on his username.
        """
        return ('zinnia_author_detail', [self.get_username()])

    def __str__(self):
        """
        If the user has a full name, use it instead of the username.
        """
        return self.get_full_name() or self.get_username()

    class Meta:
        """
        Author's meta informations.
        """
        app_label = 'zinnia'
        proxy = True
