I currently have this chunk of model code:
class Book(models.Model):
title = models.CharField(max_length=100)
num_pages = models.IntegerField(blank=True, null=True)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)
publication_date = models.DateField()
def __unicode__(self):
return self.title
class Meta:
ordering = ["title"]
If I have a book title called ‘The Fry Chronicles‘ or ‘A Hitchhikers Guide to the Galaxy‘ (for example), is there a way to get Django to ignore those short articles (an, a, the etc.) before the word within the admin interface, and just order the results by the words that follows the article?
To take it a step further, maybe there is a way to lay out the results like this…
- Fry Chronicles, The
- Hitchhikers Guide to the Galaxy, A
As to move the article to the end of the book title?
Could anybody propose a solution to the above two issues?
Thanks in advance!
I don’t think this is possible without hacking internal django admin code.
You can however do a little trick if some redundancy is not a problem. Have additional field in Book that represents title for ordering (like
clean_title) and the useorderingattribute in admin.