RecentActions with custom models

2020-02-25

The RecentActions class from Grappelli is really cool to show the latest actions on models, but the documentation doesn't really go in details on how to use the exclude_list and include_list with your custom models.

The RecentActions uses the contenttypes framework from django. If it's your first time using (directly at least), it might seems a bit weird. The rules seems to go as follow :

  • lowercase app name
  • lowercase model name
  • no space

So let's say you have a myapplication.models.SuperComment model, it would become myapplication.supercomment. To make sure it's really the case, fire up your favorite shell :

python migrate.py shell
from myapplication.models import SuperComment
from django.contrib.contenttypes.models import ContentType
ct = ContentType.objects.get_for_model(SuperComment)
print(f'{ct.app_label}.{ct.model}')

There you go!