Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
norbertschuler opened this issue Jan 20, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@norbertschuler
Copy link

norbertschuler commented Jan 20, 2024

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 norbertschuler added the bug Something isn't working label Jan 20, 2024
@fabiocaccamo
Copy link
Owner

@norbertschuler thank you for reporting this issue.

@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Jan 24, 2024

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

@norbertschuler
Copy link
Author

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.

@fabiocaccamo
Copy link
Owner

@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 fabiocaccamo closed this as not planned Won't fix, can't repro, duplicate, stale Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants