-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update to Django 4.0 #429
Merged
Merged
Update to Django 4.0 #429
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* [test_reservation_extra.py] The `localize()` method has effectively been removed (see https://docs.djangoproject.com/en/4.0/releases/4.0/#zoneinfo-default-timezone-implementation) * [requirements.txt] Also updated some other requirements - most notably `channels` from version 2 to 3, which has been long overdue * Also, replaced underscores in some of the package names with dashes, as that's what's displayed on the packages' PyPI pages * [test_locale_utils.py] `datetime_safe` has been deprecated (see https://docs.djangoproject.com/en/4.0/releases/4.0/#miscellaneous-1) * [routing.py] These changes were based on the `channels` 3.0.0 release notes (https://channels.readthedocs.io/en/stable/releases/3.0.0.html) * [static.py] `ManifestStaticFilesStorage` now uses named regex groups in its `patterns` field (see django/django@781b442)
This follows the convention seen in https://channels.readthedocs.io/en/stable/installation.html - as opposed to the convention seen in https://channels.readthedocs.io/en/2.x/installation.html. (This convention change is also mentioned in https://channels.readthedocs.io/en/stable/releases/3.0.0.html#deprecations.)
This fixes an issue with some browsers not being able to properly interpret relative URLs, and it also improves PyCharm's code suggestions in the interpolated XML files (due to it interpreting the `{% static %}` token as a Django template tag).
Or, in other words, if the user data in the database is missing some values, the missing values are replaced with data from LDAP.
There was a change in Django 4.0 that made path converters run in an async context, which caused a `SynchronousOnlyOperation` error when querying the database from a custom path converter (like subclasses of the previous `url_utils.SpecificObjectConverter`). Using `sync_to_async()` did not work, but getting the view's "focused" object through path converters (instead of e.g. through views' `get_object()` method) was an unconventional hack anyway, and so this was completely removed, and replaced by logic in the views. It can also be noted that the previously mentioned error only happened when querying the database in the path converters' `to_python()` method, not the `to_url()` method - where the former is usually invoked when Django receives a request and tries finding a view with a matching path, and the latter is mainly invoked when reversing path names while constructing a response in views and templates. This is why making database queries in `SpecificPageByTitle.to_url()` does not need to be changed. Also removed the now unused `tests.utility.template_view_get_context_data()`.
This was caused by the `create` part of request URLs being matched by the `<PageTitle:title>` path parameter of `DocumentationPageDetailView`.
This could be reproduced by running both `contentbox/tests/test_urls.py` (but not `test_views.py`) and the docs tests in the same test run. Not entirely sure where and why the tests failed, but it's possible it had something to do with the previous code in `docs/urls.py` being run when the module was imported in an earlier run test, and `Page.objects.get_or_create()` not being re-invoked when running the docs tests.
Passing positional instead of keyword arguments, makes reversing the URL less error-prone, as one doesn't have to search through the whole codebase to update the keyword argument names when the URL's path parameter is changed. Exceptions to this include reversing e.g. `machine_detail`, as the URL contains multiple (and unconventionally named) parameters, and it's easier to understand what the passed arguments are, if passed as keyword arguments.
Mainly that they're now class-based instead of function-based. Also moved and refactored some common code between the previous `get_reservation_rules()` and `get_machine_data()` views to a method on `ReservationRule` named `get_exact_start_and_end_times_list()`.
This was caused by a JavaScript error, due to the `CKEDITOR_CONFIG_FROM_DJANGO` variable not being defined, because `config_from_django.js` is not linked when the widget is a `ckeditor_uploader/widgets/CKEditorUploadingWidget` instead of a `web/widgets/CKEditorUploadingWidget` (as `Content.content` is a `RichTextUploadingField`, which is defined in the `django-ckeditor` package).
DST (daylight saving time) starts in Norway in less than a week, and so some of the tests comparing local datetimes with UTC datetimes (which is what the database provides when getting model objects with datetime fields) fail.
Also added a missing translation for "shown".
ddabble
requested review from
Maisergodt,
sigridge,
elisakiv,
Fredrikaaa and
maritmoe
March 24, 2022 13:20
Codecov Report
@@ Coverage Diff @@
## dev #429 +/- ##
==========================================
+ Coverage 88.01% 88.53% +0.52%
==========================================
Files 137 134 -3
Lines 5183 5209 +26
==========================================
+ Hits 4562 4612 +50
+ Misses 621 597 -24
Continue to review full report at Codecov.
|
This will only be active if installed - either manually or through `requirements_dev.txt`.
sigridge
approved these changes
Apr 1, 2022
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This also updates some other requirements, and replaces some deprecated features (a84d45c).
Furthermore, a change in Django 4.0 made it necessary to move database queries from path converters to views (a5eaf62).
Additional highlights:
django-extensions
(0041dc1)django-debug-toolbar
(95102f0)requirements_dev.txt
DEBUG_TOOLBAR_CONFIG
setting.