From fe33707e22786fd0efa0ec2081382299e662ed22 Mon Sep 17 00:00:00 2001 From: Malte Gerth Date: Fri, 21 Jul 2023 06:53:13 +0200 Subject: [PATCH] feat: drop unsupported django versions <3.2 --- README.rst | 2 +- docs/source/quick.rst | 56 ++++++++++++++++++++++++++++++++++--------- tox.ini | 12 +--------- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/README.rst b/README.rst index 3446aa2..c1e8138 100644 --- a/README.rst +++ b/README.rst @@ -64,7 +64,7 @@ Requirements - Python 2.7 or 3.5+ - jQuery 1.7+ -- Django 1.8 to 4.0 +- Django 3.2 to 4.0 - django.contrib.staticfiles or #YoYo Resources diff --git a/docs/source/quick.rst b/docs/source/quick.rst index 6094a86..5009730 100644 --- a/docs/source/quick.rst +++ b/docs/source/quick.rst @@ -7,24 +7,58 @@ because your time matters and you probably have other things to worry about. Install the package:: pip install django-session-security - # or the development version - pip install -e git+git://github.com/yourlabs/django-session-security.git#egg=django-session-security -For static file service, add to ``settings.INSTALLED_APPS``:: +For static file service, add ``session_security`` to your ``INSTALLED_APPS`` settings: - 'session_security', +.. code-block:: python -Add to ``settings.MIDDLEWARE_CLASSES``, **after** django's AuthenticationMiddleware:: + INSTALLED_APPS = [ + # ... + 'session_security', + # ... + ] - 'session_security.middleware.SessionSecurityMiddleware', +Add ``session_security.middleware.SessionSecurityMiddleware`` to your ``MIDDLEWARE`` settings: -Ensure settings.TEMPLATE_CONTEXT_PROCESSORS has:: +.. code-block:: python - 'django.core.context_processors.request' + MIDDLEWARE = [ + # ... + 'session_security.middleware.SessionSecurityMiddleware', + # ... + ] -Add to urls:: +.. warning:: - url(r'session_security/', include('session_security.urls')), + The order of ``MIDDLEWARE`` is important. You should include the ``django-session-security`` middleware + after the authentication middleware, such as :class:`~django.contrib.auth.middleware.AuthenticationMiddleware`. + +Ensure ``django.template.context_processors.request`` is added to the template context processors: + +.. code-block:: python + + TEMPLATES = [ + { + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.request", + # ... + ] + } + # ... + } + ] + +Add ``session_security`` URLs to your project’s URLconf: + +.. code-block:: python + + from django.urls import include, path + + urlpatterns = [ + # ... + path('session_security/', include('session_security.urls')), + ] At this point, we're going to assume that you have `django.contrib.staticfiles `_ working. @@ -32,7 +66,7 @@ This means that `static files are automatically served with runserver `_, and that you have to run `collectstatic when using another server `_ -(fastcgi, uwsgi, and whatnot). If you don't use django.contrib.staticfiles, +(fastcgi, uwsgi, and whatnot). If you don't use `django.contrib.staticfiles`, then you're on your own to manage staticfiles. After jQuery, add to your base template:: diff --git a/tox.ini b/tox.ini index 753e206..682572d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,6 @@ [tox] envlist = - py{27,35,36}-django{18,19,110,111} - py{35,36,37,38}-django{111,22} - py{36,37,38,39,310}-django{30,31,32} - py{38,39,310}-django{40,41} + py{38,39,310}-django{32,40,41} [testenv] usedevelop = true commands = @@ -12,13 +9,6 @@ deps = coverage unittest-data-provider selenium<4.3.0 - django18: Django>=1.8,<1.9 - django19: Django>=1.9,<1.10 - django110: Django>=1.10,<1.11 - django111: Django>=1.11,<1.12 - django22: Django>=2.2,<2.3 - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 django32: Django>=3.2,<3.3 django40: Django>=4.0,<4.1 django41: Django>=4.1,<4.2