Skip to content

Commit

Permalink
Add support for django 4.0. Fix various deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kluchrj committed Jan 10, 2022
1 parent 4cc7e9c commit af66f4f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: 2

sphinx:
configuration: docs/conf.py

build:
os: ubuntu-20.04
tools:
python: "3.10"

python:
install:
- method: setuptools
path: .
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ v1.0.5 (Released 1/10/2022)
---------------------------

- Added core support for retrieving Django Rest Framework class instances on DRF views. Note that you will still need to write a custom processor to parse these views. Thanks @jeffgabhart!
- Added support for Django 4.0. Fixed various deprecation warnings.
- Added Python 3.10 and Django 4.0 to the test matrix. Removed unsupported Django 3.0 and 3.1 versions.


Expand Down
6 changes: 4 additions & 2 deletions permissions_auditor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

__version__ = '1.0.5'


default_app_config = 'permissions_auditor.apps.PermissionsAuditorConfig'
# This can be removed once Django 3.1 and below support is dropped.
from django import VERSION as DJANGO_VERSION
if DJANGO_VERSION < (3, 1):
default_app_config = 'permissions_auditor.apps.PermissionsAuditorConfig'
2 changes: 2 additions & 0 deletions permissions_auditor/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class PermissionsAuditorConfig(AppConfig):
name = 'permissions_auditor'
verbose_name = _('Permissions Auditor')

default_auto_field = 'django.db.models.BigAutoField'

def ready(self):
# Delete the cached views list on application reload.
cache.delete_many([
Expand Down
31 changes: 23 additions & 8 deletions permissions_auditor/tests/fixtures/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from django.conf.urls import url, include as old_include

from django import VERSION as DJANGO_VERSION

if DJANGO_VERSION < (4, 0):
# This can be removed once Django 3.2 and below support is dropped.
from django.conf.urls import url, include as old_include

from django.urls import path, include, re_path

from . import views
Expand All @@ -12,17 +18,26 @@
path('staff_member_required/', views.staff_member_required_view),
], 'admin')

old_style_urls = ([
url(r'^login_required/$', views.LoginRequiredView.as_view()),
url(r'^perm_required/$', views.PermissionRequiredView.as_view()),
], 'old_style_urls')

urlpatterns = [
path('', views.BaseView.as_view()),
path('multi_perm_view/', views.PermissionRequiredMultiView.as_view()),

path('new_style/', include(new_style_urls)),
path('admin/', include(admin_namespace)),

url('old_style/', old_include(old_style_urls)),
]

if DJANGO_VERSION < (4, 0):
# This can be removed once Django 3.2 and below support is dropped.
old_style_urls = ([
url(r'^login_required/$', views.LoginRequiredView.as_view()),
url(r'^perm_required/$', views.PermissionRequiredView.as_view()),
], 'old_style_urls')

urlpatterns += [url('old_style/', old_include(old_style_urls))]
else:
old_style_urls = ([
re_path(r'^login_required/$', views.LoginRequiredView.as_view()),
re_path(r'^perm_required/$', views.PermissionRequiredView.as_view()),
], 'old_style_urls')

urlpatterns += [path('old_style/', include(old_style_urls))]

0 comments on commit af66f4f

Please sign in to comment.