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

Appending to MIDDLEWARE happens twice #948

Closed
nniehoff opened this issue Sep 27, 2021 · 3 comments · Fixed by #1022
Closed

Appending to MIDDLEWARE happens twice #948

nniehoff opened this issue Sep 27, 2021 · 3 comments · Fixed by #1022
Labels
type: bug Something isn't working as expected type: documentation Improvements or additions to documentation

Comments

@nniehoff
Copy link
Contributor

Environment

  • Python version: 3.6
  • Nautobot version: 1.1.3

Steps to Reproduce

  1. In nautobot_config.py append to MIDDLEWARE such as:
MIDDLEWARE.append("some new fancy middleware")
  1. Start a python shell invoke nbshell
  2. Check the MIDDLEWARE value:
from django.conf import settings
settings.MIDDLEWARE

Expected Behavior

The appended value "some new fancy middleware" should be added 1 time.

Observed Behavior

"some new fancy middleware" is appended to the array twice.

Workaround

if "some new fancy middleware" not in MIDDLEWARE:
    MIDDLEWARE.append("some new fancy middleware")
@nniehoff
Copy link
Contributor Author

I suspect this is similar to the original issue with INSTALLED_APPS and ultimately we added EXTRA_INSTALLED_APPS which something like EXTRA_MIDDLEWARE might address but order matters in MIDDLEWARE so maybe not.

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Oct 1, 2021
@jathanism
Copy link
Contributor

Correct. What you should be doing is using EXTRA_MIDDLEWARE so that it is only done once. I know we have this documented, here for extra applications but not for middleware:

https://nautobot.readthedocs.io/en/stable/configuration/optional-settings/#extra-applications

I think we should use this as an excuse to update the documentation to also include "extra middleware" and an example.

@jathanism jathanism added the type: documentation Improvements or additions to documentation label Oct 22, 2021
@nniehoff
Copy link
Contributor Author

Thanks @jathanism I'll work on a PR

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected type: documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants