django-admin-interface icon indicating copy to clipboard operation
django-admin-interface copied to clipboard

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

Open norbertschuler opened this issue 1 year ago • 3 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 https://github.com/fabiocaccamo/django-admin-interface/blob/e895a057fe3a3ad6ab89c00b9b5983385a664aac/admin_interface/templatetags/admin_interface_tags.py#L28 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 avatar Jan 20 '24 12:01 norbertschuler

@norbertschuler thank you for reporting this issue.

fabiocaccamo avatar Jan 20 '24 15:01 fabiocaccamo

@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")

fabiocaccamo avatar Jan 24 '24 21:01 fabiocaccamo

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 avatar Jan 25 '24 05:01 norbertschuler

@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).

fabiocaccamo avatar Feb 14 '24 17:02 fabiocaccamo