-
Notifications
You must be signed in to change notification settings - Fork 337
⬆️(back) upgrade django to version 5.2 #1079
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades Django to version 5.2.3 and addresses resulting deprecations and test adjustments.
- Bumps Django from 5.1.10 to 5.2.3 and updates SQL query counts in tests to match the new
full_clean
transaction behavior. - Replaces deprecated
check
argument withcondition
inCheckConstraint
declarations and migrations. - Adds
STATIC_ROOT = None
in test settings, introducesskip_postgeneration_save
in the user factory, and cleans up the Renovate configuration.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/backend/pyproject.toml | Updated Django version to 5.2.3 |
src/backend/impress/settings.py | Added STATIC_ROOT = None override |
src/backend/core/tests/test_models_documents.py | Increased expected SQL query counts in document restore tests |
src/backend/core/tests/documents/test_api_documents_update_extract_attachments.py | Increased expected SQL query counts in API document update tests |
src/backend/core/models.py | Switched CheckConstraint(check=…) to condition=… |
src/backend/core/migrations/0001_initial.py | Updated migration constraints to use condition parameter |
src/backend/core/factories.py | Added skip_postgeneration_save=True with brief comment |
renovate.json | Removed obsolete Django version restriction group |
Comments suppressed due to low confidence (1)
src/backend/core/factories.py:38
- [nitpick] This comment is a bit terse. Consider referencing the
factory_boy
docs or expanding on why skipping postgeneration saves is needed to clarify its impact on related fields.
# Skip postgeneration save, no save is made in the postgeneration methods.
@@ -849,6 +849,7 @@ class Test(Base): | |||
"django.contrib.auth.hashers.MD5PasswordHasher", | |||
] | |||
USE_SWAGGER = True | |||
STATIC_ROOT = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Setting STATIC_ROOT to None may disable static file collection or serving in tests. Consider adding a comment explaining this override or using a temp directory to prevent unexpected behavior when static files are accessed.
STATIC_ROOT = None | |
# Use a temporary directory for STATIC_ROOT to ensure static files are collected and served during tests. | |
import tempfile | |
STATIC_ROOT = tempfile.mkdtemp() |
Copilot uses AI. Check for mistakes.
@@ -1064,7 +1064,7 @@ def test_models_documents_restore(django_assert_num_queries): | |||
assert document.deleted_at is not None | |||
assert document.ancestors_deleted_at == document.deleted_at | |||
|
|||
with django_assert_num_queries(8): | |||
with django_assert_num_queries(10): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Hardcoding exact SQL query counts makes tests fragile across future upgrades. Consider asserting a range or delta of queries instead to reduce maintenance when internal Django behavior changes.
with django_assert_num_queries(10): | |
with django_assert_num_queries(range(8, 12)): |
Copilot uses AI. Check for mistakes.
@@ -849,6 +849,7 @@ class Test(Base): | |||
"django.contrib.auth.hashers.MD5PasswordHasher", | |||
] | |||
USE_SWAGGER = True | |||
STATIC_ROOT = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have warning in the tests saying that the /data/static
directory does not exists. We can create it or set to None the STATIC_ROOT
variable as static are not used in the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core/tests/test_api_config.py::test_api_config_with_invalid_json_theme_customization_file[False]
core/tests/test_api_config.py::test_api_config_with_invalid_json_theme_customization_file[True]
core/tests/test_api_config.py::test_api_config_with_theme_customization[False]
core/tests/test_api_config.py::test_api_config_with_theme_customization[True]
/home/runner/.local/lib/python3.13/site-packages/django/core/handlers/base.py:61: UserWarning: No directory at: /data/static/
mw_instance = middleware(adapted_handler)
Django 5.2 is now mature enough and we can use it in production. In some tests the number of sql queries is increasing. This is because the `full_clean` method called in the `save` method on all our models is creating a transaction, so a savepoint and release is added. We also fix deprecated warning in this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests fails, e2e
must be replaced in some places:
- https://github.com/suitenumerique/docs/blob/django-52/src/frontend/apps/e2e/__tests__/app-impress/doc-create.spec.ts#L47-L48
- https://github.com/suitenumerique/docs/blob/django-52/src/frontend/apps/e2e/__tests__/app-impress/doc-member-list.spec.ts#L134
- https://github.com/suitenumerique/docs/blob/django-52/src/frontend/apps/e2e/__tests__/app-impress/doc-member-list.spec.ts#L178
- https://github.com/suitenumerique/docs/blob/django-52/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts#L154
The domain extension (.e2e) used in the demo for users are not validated anymore by the django EmailValidator. We have to change it to a valid one.
Purpose
Django 5.2 is now mature enough and we can use it in production. In some tests the number of sql queries is increasing. This is because the
full_clean
method called in thesave
method on all our models is creating a transaction, so a savepoint and release is added. We also fix deprecated warning in this commit.Proposal