blubber / django_injector

Dependency injection in Django.
BSD 2-Clause "Simplified" License
49 stars 7 forks source link

Migrating from 0.2.5 to 0.3.1 #23

Closed jrosalesmeza closed 6 months ago

jrosalesmeza commented 1 year ago

Hello everyone, after updating the library to the latest version, I try to run my project but I get the following error related to this library, do you have any idea why it could be happening?

I have the following libraries installed:

In addition to the above, the following tests were performed, but they did not work either: 1 - Django and DRF in current version (4.0.4 and 3.xx) and updating Django-Injector version to 0.3.1. 2- Django and DRF to the latest version without upgrading Django-Injector (0.2.5) 3- Django and DRF to the latest version with the latest version of Django-Injector (0.3.1)

  File "/Users/jrosalesmeza/Desktop/apps/app/.venv/lib/python3.11/site-packages/django/utils/module_loading.py", line 32, in import_string
    raise ImportError(
ImportError: Module "django_injector" does not define a "inject_request_middleware" attribute/class

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/jrosalesmeza/Desktop/apps/app/.venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/jrosalesmeza/Desktop/apps/app/.venv/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 157, in inner_run
    handler = self.get_handler(*args, **options)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jrosalesmeza/Desktop/apps/app/.venv/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 78, in get_handler
    return get_internal_wsgi_application()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jrosalesmeza/Desktop/apps/app/.venv/lib/python3.11/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'config.wsgi.application' could not be loaded; Error importing module.
mvdbos commented 6 months ago

@jrosalesmeza I had the same error, turns out you should not add it to MIDDLEWARE in settings.py but to MIDDLEWARES. Note the 'S' at the end. I guess these are middlewares specific to django_injector.

blubber commented 6 months ago

No it should really be MIDDLEWARE, but I think this is related to a typo in the readme, see this pr.