Skip to content

Commit

Permalink
Use more readable app name on admin index page
Browse files Browse the repository at this point in the history
  • Loading branch information
treyhunner committed May 13, 2013
1 parent efdfe9d commit 7953d5c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions email_log/models.py
Expand Up @@ -3,6 +3,8 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from .utils import string_with_title


@python_2_unicode_compatible
class Email(models.Model):
Expand All @@ -21,3 +23,4 @@ def __str__(self):

class Meta:
ordering = ('-date_sent',)
app_label = string_with_title('email_log', "Email log")
22 changes: 22 additions & 0 deletions email_log/utils.py
@@ -0,0 +1,22 @@
class string_with_title(str):

"""
Custom string with title() method
Based on code from
https://ionelmc.wordpress.com/2011/06/24/custom-app-names
"""

def __new__(cls, value, title):
instance = str.__new__(cls, value)
instance._title = title
return instance

def title(self):
return self._title

def __copy__(self):
return self

def __deepcopy__(self, memodict):
return self

0 comments on commit 7953d5c

Please sign in to comment.