InstallΒΆ

Install with the pip package manager.

$ mkvirtualenv myvenv -p python3
$ pip install django
$ pip install django-removewww

After creating a project, add removewww.middleware.RemoveWwwMiddleware to MIDDLEWARE in settings.py. Set the REMOVE_WWW boolean to True.

MIDDLEWARE = [
    # ...
    'removewww.middleware.RemoveWwwMiddleware',
]

REMOVE_WWW = True

Adding to INSTALLED_APPS is unnecessary unless you want to run the tests.

The middleware is compatible with pre-Django 1.10-style middleware because it inherits from django.utils.deprecation.MiddlewareMixin.

Remember to update your requirements.txt file. In your project directory:

$ pip freeze > requirements.txt