[SOLVED] Cannot override get_admin_log

Hi django community!

Here a little question, about overriding get_admin_log. Indeed, on the default Django Administration (/admin/), there is a Recent actions toolbar, which prints last adds, deletes, edits… on models. I want to only print last add.

So, I take the venv/lib/python3.7/site-packages/django/contrib/admin/templates/admin/index.html and copy it in myproject/myapp/templates/admin/index.html. If I edit this file, it’s OK. So, I can add and remove some template codes. Good!

Now, I have to add a filter for the LogEntry.objects request in AdminLogNode, for only print new creations in the Recent actions toolbar. So:

  • I copy venv/lib/python3.7/site-packages/django/contrib/templatetags/log.py in myproject/myapp/templatetags/log.py.
  • I changed my settings.py, and made sure than my app is loaded before django.contrib.admin.
  • However, all my changes in this file are not executed. It seems the default file is still used, and my the overrided one isn’t. If I write a python error, I get an error, so, the file is readed. But if I write a print(), it does not work, so the function seems to be never called.

Did I miss something for my overrided function be executed? I made the same action for override a template file and a function file, and the one works fine.

Thanks a lot for your advices!


Ok, get it!

I based my actions on this discussion, where they said the opposite. You have to place your app AFTER django.contrib.admin in settings.py.