Skip to content

replace serializers.PickleSerializer with JSONSerializer#990

Merged
jsjiang merged 1 commit intodevelopfrom
989_replace_PickleSerializer_with_JSONSerializer
Feb 10, 2026
Merged

replace serializers.PickleSerializer with JSONSerializer#990
jsjiang merged 1 commit intodevelopfrom
989_replace_PickleSerializer_with_JSONSerializer

Conversation

@jsjiang
Copy link
Contributor

@jsjiang jsjiang commented Feb 5, 2026

@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.db is the default Django setting. I am adding it explicitly so we know that session data is stored in the database in the django_session table.

Please review.

Thank you

Jing

Copy link

Copilot AI left a 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 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.PickleSerializer with JSONSerializer in 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"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
SESSION_ENGINE = "django.contrib.sessions.backends.db"
SESSION_ENGINE = 'django.contrib.sessions.backends.db'

Copilot uses AI. Check for mistakes.
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"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
SESSION_ENGINE = "django.contrib.sessions.backends.db"
SESSION_ENGINE = 'django.contrib.sessions.backends.db'

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@sfisher sfisher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jsjiang . This works fine for me.

I guess this may require users to obtain a new session when it's deployed (log in again)? I think this is fine and it sounds like you have a plan for that.

@jsjiang
Copy link
Contributor Author

jsjiang commented Feb 10, 2026

Thanks @jsjiang . This works fine for me.

I guess this may require users to obtain a new session when it's deployed (log in again)? I think this is fine and it sounds like you have a plan for that.

Yes. All active sessions will be deleted and user will need to re-authenticate after EZID is back up with the new configurations.

@jsjiang jsjiang merged commit 0c100ae into develop Feb 10, 2026
8 checks passed
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.

2 participants

Comments