adminfor basic data manipulation, or
flatpagesfor the dynamic content that tends to be rarely changed. Sometimes you want to use them, but their functionality doesn't completely fit your needs.
You have several options in that case:
- Use custom models with one-to-one or many-to-one relations, creating extensions for existing models. The main drawback of this approach is that those custom models will be editable in the contributed administration separately from the origin or you will need to create custom views to combine everything nicely.
- Use modified duplicates instead of the contributed applications. The main drawback of this case is that it will be hard to manage the updates of the models.
- Use signals to modify the models. This can be too complicated for simple changes.
- Modify the properties of the models on the fly.
INSTALLED_APPSsetting. As Python is an interpreted language and all methods and properties are public, you can access and change them on the fly.
For example, if your task is to rename verbose name of groups to "Roles" and show related users at the list view of contributed administration, then it can be achieved by the following code in some model which application appears somewhere below the
# -*- coding: UTF-8 -*-
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import Group
""" A function modifying the contributed Group model """
# modifying the verbose names
Group._meta.verbose_name = _("Role")
Group._meta.verbose_name_plural = _("Roles")
""" A function displaying users for a group """
links = 
for user in group.user_set.all():
"""<a href="/admin/auth/user/%d">%s</a>""" % (
("%s %s" % ( # show the real name
user.last_name, # or the username
)).strip() or user.username,
return "<br />".join(links)
display_users.allow_tags = True
display_users.short_description = _("Users")
# attaching the new function to the Group model
Group.display_users = display_users
# changing the list_display for the Group model
Group._meta.admin.list_display = ("__str__", "display_users")
As you might see from this example,
Adminclass for the
Groupmodel. You can prove it to yourself by browsing objects in Django shell aka Python IDE.
Use this kind of hacking whenever you reasonably need to change Django core functionalities or some third party modules and have no other choice. However, don't overuse it, 'cause it might lead to difficulties in maintaining the project.