replace serializers.PickleSerializer with JSONSerializer#990
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Django session configuration to prepare for Django 5 compatibility by replacing the deprecated PickleSerializer with JSONSerializer. Additionally, it explicitly sets the SESSION_ENGINE to the database backend, which is already Django's default.
Changes:
- Replaced
django.contrib.sessions.serializers.PickleSerializerwithJSONSerializerin both settings files - Added explicit
SESSION_ENGINE = "django.contrib.sessions.backends.db"configuration
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| settings/tests.py | Updated session serializer to JSONSerializer and added explicit session engine configuration for test settings |
| settings/settings.py.j2 | Updated session serializer to JSONSerializer and added explicit session engine configuration for production settings template |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SESSION_EXPIRE_AT_BROWSER_CLOSE = True | ||
| SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' | ||
| SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' | ||
| SESSION_ENGINE = "django.contrib.sessions.backends.db" |
There was a problem hiding this comment.
Inconsistent quote style: SESSION_ENGINE uses double quotes while SESSION_SERIALIZER and SESSION_COOKIE_PATH use single quotes. For consistency with the surrounding code, SESSION_ENGINE should use single quotes.
| SESSION_ENGINE = "django.contrib.sessions.backends.db" | |
| SESSION_ENGINE = 'django.contrib.sessions.backends.db' |
| SESSION_EXPIRE_AT_BROWSER_CLOSE = True | ||
| SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' | ||
| SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' | ||
| SESSION_ENGINE = "django.contrib.sessions.backends.db" |
There was a problem hiding this comment.
Inconsistent quote style: SESSION_ENGINE uses double quotes while SESSION_SERIALIZER and SESSION_COOKIE_PATH use single quotes. For consistency with the surrounding code, SESSION_ENGINE should use single quotes.
| SESSION_ENGINE = "django.contrib.sessions.backends.db" | |
| SESSION_ENGINE = 'django.contrib.sessions.backends.db' |
Yes. All active sessions will be deleted and user will need to re-authenticate after EZID is back up with the new configurations. |
@sfisher Hi Scott,
This is to replace django.contrib.sessions.serializers.PickleSerializer with JSONSerializer which will be the only session serializer in Django 5.
The
SESSION_ENGINE = "django.contrib.sessions.backends.dbis the default Django setting. I am adding it explicitly so we know that session data is stored in the database in thedjango_sessiontable.Please review.
Thank you
Jing