Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Django 4.2 #72

Merged
merged 10 commits into from
Nov 20, 2023
Merged

Add support for Django 4.2 #72

merged 10 commits into from
Nov 20, 2023

Conversation

gherceg
Copy link
Contributor

@gherceg gherceg commented Nov 13, 2023

Python 3.7 has been EOLed, so remove that and run against newer versions of Python as well (3.10 and 3.11).

And in anticipation for Django 3.2 being EOLed in April 2024, we should update tests to run against both 3.2 and 4.2 LTS.

- no longer runs tests against 3.7 as it as been EOLed
@coveralls
Copy link

coveralls commented Nov 13, 2023

Coverage Status

coverage: 90.491% (-0.08%) from 90.575%
when pulling 538989a on gh/tests/update-versions
into 43e1d2a on master.

@gherceg
Copy link
Contributor Author

gherceg commented Nov 13, 2023

I'm planning to create a separate PR officially adding support for 4.2 until I've done some due diligence, but passing tests is a promising start.

Update: I read through breaking changes introduced in 4.0 and feel confident that django-prbac is not relying on any of these. I'm thinking of updating the allowed django versions in this PR as well. Any thoughts @millerdev?

@millerdev
Copy link
Contributor

👍 Sounds good to me.

- support python 3.8 - 3.11
- support django 3 and 4, drop support for 2
setup.py Show resolved Hide resolved
@gherceg gherceg changed the title Update python and django versions that tests run against Update supported python and django versions Nov 14, 2023
@gherceg
Copy link
Contributor Author

gherceg commented Nov 17, 2023

I realized that the "tests passing on 4.2" before was due to pip install -e . uninstalling 4.2 and installing 3.2 based on the requirements of django-prbac:

(test-prbac) ⏺ code/django-prbac % pip install -e .                                                                                                        I
Obtaining file:///home/gherceg/dimagi/code/django-prbac
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting simplejson
  Using cached simplejson-3.19.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (137 kB)
Collecting jsonfield<4,>=1.0.3
  Using cached jsonfield-3.1.0-py3-none-any.whl (8.0 kB)
Collecting django!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,!=3.0.4,!=3.0.5,!=3.0.6,<4,>=2.2.13
  Using cached Django-3.2.23-py3-none-any.whl (7.9 MB)
Requirement already satisfied: asgiref<4,>=3.3.2 in /home/gherceg/.pyenv/versions/3.10.13/envs/test-prbac/lib/python3.10/site-packages (from django!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,!=3.0.4,!=3.0.5,!=3.0.6,<4,>=2.2.13->django-prbac==1.0.1) (3.7.2)
Requirement already satisfied: sqlparse>=0.2.2 in /home/gherceg/.pyenv/versions/3.10.13/envs/test-prbac/lib/python3.10/site-packages (from django!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,!=3.0.4,!=3.0.5,!=3.0.6,<4,>=2.2.13->django-prbac==1.0.1) (0.4.4)
Collecting pytz
  Using cached pytz-2023.3.post1-py2.py3-none-any.whl (502 kB)
Requirement already satisfied: typing-extensions>=4 in /home/gherceg/.pyenv/versions/3.10.13/envs/test-prbac/lib/python3.10/site-packages (from asgiref<4,>=3.3.2->django!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,!=3.0.4,!=3.0.5,!=3.0.6,<4,>=2.2.13->django-prbac==1.0.1) (4.8.0)
Building wheels for collected packages: django-prbac
  Building editable for django-prbac (pyproject.toml) ... done
  Created wheel for django-prbac: filename=django_prbac-1.0.1-0.editable-py2.py3-none-any.whl size=5489 sha256=e60fd515114b09e4631fc606fbcb32f47f9f88621964cc74d83cb3fbe811c5cc
  Stored in directory: /tmp/pip-ephem-wheel-cache-hur7cz7q/wheels/bd/da/41/b249f1a4df4f534ff0409ca07b413ddbd1999f217a44ba2f6a
Successfully built django-prbac
Installing collected packages: pytz, simplejson, django, jsonfield, django-prbac
  Attempting uninstall: django
    Found existing installation: Django 4.2.7
    Uninstalling Django-4.2.7:
      Successfully uninstalled Django-4.2.7
Successfully installed django-3.2.23 django-prbac-1.0.1 jsonfield-3.1.0 pytz-2023.3.post1 simplejson-3.19.2

There were a couple of changes in Django 4 that needed to be addressed here:

  • django.conf.urls.url has been replaced by django.urls.re_path|path
  • django-admin.py has been replaced by django-admin
  • when an unsaved db object attempts to access a foreign key relationship, a ValueError exception is raised

I've addressed these in this PR as well, so tests for 4.2 now pass.

@gherceg gherceg changed the title Update supported python and django versions Add support for Django 4.2 Nov 17, 2023
Django 4 raises a ValueError when attempting to read a fk relationship
on an unsaved model, rather than return an empty list.
django_prbac/models.py Outdated Show resolved Hide resolved
@gherceg gherceg merged commit f8ad9b2 into master Nov 20, 2023
@gherceg gherceg deleted the gh/tests/update-versions branch November 20, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants