citusdata / django-multitenant

Python/Django support for distributed multi-tenant databases like Postgres+Citus
MIT License
707 stars 116 forks source link

ModuleNotFoundError: No module named 'django_multitenant.middleware' #208

Open hexmo opened 6 months ago

hexmo commented 6 months ago

Problem

I got this error when integrating this library with the Django Rest Framework. I was following this guide. But after adding this section to my setting.py file, I got the above error.

MIDDLEWARE = [
    # other middleware
    'django_multitenant.middleware.MultitenantMiddleware',
]

I wasted a lot of time rechecking and reinstalling the project ensuring everything was done as outlined by the documentation. However, there was a minor spelling mistake in the documentation itself. The middlewares module is shown as middleware in the docs that I discovered after checking the source code.

Solution

MIDDLEWARE = [
    # other middleware
    # Add the missing 's' to middleware
    'django_multitenant.middlewares.MultitenantMiddleware',
]