fabiocaccamo/django-admin-interface

Unnecessary warning for missing django.middleware.locale.LocaleMiddleware if using customized middleware

norbertschuler opened this issue ยท 4 comments

Python version
3.11.7

Django version
4.2.8

Package version
0.28.3

Current behavior (bug description)
If you do not use django.middleware.locale.LocaleMiddleware in your settings.MIDDLEWARE but have an own custom middleware inheriting from django.middleware.locale.LocaleMiddleware the code at

if "django.middleware.locale.LocaleMiddleware" not in settings.MIDDLEWARE:
throws an unnecessary warning.

Expected behavior
Omit the warning or think about another way to not throw an unnecessary warning?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

@norbertschuler thank you for reporting this issue.

@norbertschuler to avoid this warning when using a middleware subclass would require to import and check all middlewares everytime the template tag is called, now I'm wondering: wouldn't adding this check add too much overhead to avoid a simple warning which only purpose is to help users in case of setup mistakes?

In the meantime, have you tried to ignore the warning?

import warnings

warnings.filterwarnings("ignore", module="admin_interface.templatetags.admin_interface_tags")

In the meantime, have you tried to ignore the warning?

import warnings



warnings.filterwarnings("ignore", module="admin_interface.templatetags.admin_interface_tags")

In fact we are now already doing this.

@norbertschuler I added this to the FAQ section:
https://github.com/fabiocaccamo/django-admin-interface?tab=readme-ov-file#custom-localemiddleware-warning

I close this because it's not my intention to add this extra-check (as explained before).