-
Notifications
You must be signed in to change notification settings - Fork 374
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
[django] upgraded django to 4.1 #3945
base: master
Are you sure you want to change the base?
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.
looks good.
b6ef65f
to
e1a6f9b
Compare
e1a6f9b
to
ac0a9dd
Compare
Several other libraries have also been upgraded along with it. Four code changes had to be made. 1. Django 4 wants the middlewares to be explicitly sync and async. Rather than rewriting all of the middleware classes, I took the shortcut of creating a new mixin class that supports only sync calls. 2. CSRF_TRUSTED_ORIGINS in django 4+ need the scheme part as well. We now check and add `http` and `https` to the origins. 3. django-babel also needs a change every time we do a django upgrade. This is mostly just changes around django version support.
ac0a9dd
to
1ab7b15
Compare
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.
Added few review comments
''' | ||
Django4MiddlewareAdapterMixin has been solely added to migrate | ||
Django3 middleware classes to Django4. Any new middleware | ||
classes should try not to use this and instead follow the | ||
standard practice at the time. | ||
''' |
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.
Add it as a docstring?
for origin in TRUSTED_ORIGINS: | ||
if 'http://' in origin or 'https://' in origin: | ||
CSRF_TRUSTED_ORIGINS.append(origin) | ||
else: | ||
CSRF_TRUSTED_ORIGINS.append('http://%s' % origin) | ||
CSRF_TRUSTED_ORIGINS.append('https://%s' % origin) |
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.
I'm a bit confused here @amitsrivastava , so if the origin
is present in TRUSTED_ORIGINS, we are always appending one value in
CSRF_TRUSTED_ORIGINS` else we are always appending two values for the same origin? Any reason why?
Several other libraries have also been upgraded along with it. Three code changes had to be made.
Django 4 wants the middlewares to be explicitly sync and async. Rather than rewriting all of the middleware classes, I took the shortcut of creating a new mixin class that supports only sync calls.
CSRF_TRUSTED_ORIGINS in django 4+ need the scheme part as well. We now check and add
http
andhttps
to the origins.django-babel also needs a change every time we do a django upgrade. This is mostly just changes around django version support.
There is also some change to our database support due to this. Following is the list of supported db versions.
What changes were proposed in this pull request?
How was this patch tested?
Please review Hue Contributing Guide before opening a pull request.