v0.150.0

plain-sessions changelog

0.45.6 (2026-05-25)

What's changed

  • Internal: model field declarations updated for plain.postgres's new parameterized-descriptor field typing. (229ecdbbfa)

Upgrade instructions

  • No changes required.

0.45.5 (2026-05-05)

What's changed

  • Exposes __version__ from importlib.metadata on plain.sessions for version probes that don't want to scrape pip metadata. (c6cf6edb)

Upgrade instructions

  • No changes required.

0.45.4 (2026-04-17)

What's changed

  • Updated Session for plain-postgres 0.96.0: created_at uses DateTimeField(create_now=True), and session_data uses literal default={} (callable default=dict is no longer allowed). (5d145e4, 091bac7)

Upgrade instructions

  • Requires plain-postgres>=0.96.0. Run plain postgres sync after upgrading to reconcile column defaults.

0.45.3 (2026-04-14)

What's changed

  • Updated the ClearExpired chore to the new QuerySet.delete() return type (an int directly instead of a (count, by_label) tuple) from plain-postgres 0.95.0. (29e10dba51d9)
  • Added explicit plain.postgres>=0.95.0 dependency — the package has always imported plain.postgres APIs but previously relied on it being present transitively.

Upgrade instructions

  • Requires plain-postgres>=0.95.0.

0.45.2 (2026-04-13)

What's changed

  • Migrated type suppression comments to ty: ignore for the new ty checker version. (4ec631a7ef51)

Upgrade instructions

  • No changes required.

0.45.1 (2026-03-29)

What's changed

  • Removed AddIndex and RenameIndex operations from migrations — indexes are now managed by convergence. (c58b4ba1fec9)
  • Updated docs to reference plain postgres sync instead of plain migrate. (b026895edc4c)

Upgrade instructions

  • No changes required.

0.45.0 (2026-03-28)

What's changed

  • Replaced CharField with TextField in models and migration files to match plain-postgres 0.90.0 (5062ee4dd1fd)

Upgrade instructions

  • Requires plain-postgres>=0.90.0
  • Replace CharField with TextField in migration files that reference this package's models

0.44.1 (2026-03-25)

What's changed

  • Renamed indexes to use readable {table}_{column}_idx naming convention, replacing the old truncated hash-based names. Includes a migration with RenameIndex operations (instant ALTER INDEX RENAME, no locks). (74aa8b76aa40)

Upgrade instructions

  • Run plain migrate to apply the index rename migration. This is an instant metadata-only operation with no performance impact.

0.44.0 (2026-03-12)

What's changed

  • Updated all imports from plain.models to plain.postgres in core, models, and migrations.
  • Updated pyproject.toml dev dependency from plain.models to plain.postgres.

Upgrade instructions

  • Update imports: from plain.models to from plain.postgres, from plain import models to from plain import postgres.
  • Update dependency declarations: plain.models to plain.postgres in pyproject.toml.

0.43.0 (2026-03-06)

What's changed

  • Adapted SessionMiddleware to the new middleware API — session loading moved to before_request() (returns None to continue), and session saving/cookie management moved to after_response(). Removed self.get_response() call (9a1477ee8fa8)

Upgrade instructions

  • Requires plain>=0.116.0. No other changes required.

0.42.4 (2026-02-26)

What's changed

  • Added type annotations to all session cookie settings so they can be set via environment variables (37e8a58ca9b5)

Upgrade instructions

  • No changes required.

0.42.3 (2026-02-26)

What's changed

  • Auto-formatted config files with updated linter configuration (028bb95c3ae3)

Upgrade instructions

  • No changes required.

0.42.2 (2026-02-04)

What's changed

  • Added __all__ exports to middleware, models, test, and views modules for explicit public API boundaries (e7164d3891b2)

Upgrade instructions

  • No changes required.

0.42.1 (2026-01-28)

What's changed

Upgrade instructions

  • No changes required.

0.42.0 (2026-01-15)

What's changed

  • Session admin list view now displays a description for better clarity in the admin interface (0fc4dd3)

Upgrade instructions

  • No changes required

0.41.0 (2026-01-13)

What's changed

  • README documentation has been standardized with improved structure including a new FAQs section, better code examples, and clearer explanations (da37a78)

Upgrade instructions

  • No changes required

0.40.1 (2025-11-24)

What's changed

  • Documentation updated to fix remaining references to SessionViewMixin that should be SessionView (d0b41a0)

Upgrade instructions

  • No changes required

0.40.0 (2025-11-24)

What's changed

  • SessionViewMixin has been replaced with SessionView, a class that directly inherits from View. This provides better type inference for IDE autocomplete and type checkers (569afd6)

Upgrade instructions

  • Replace class MyView(SessionViewMixin, View) with class MyView(SessionView) and update your import from from plain.sessions.views import SessionViewMixin to from plain.sessions.views import SessionView

0.39.1 (2025-11-17)

What's changed

  • The Session model's query class variable no longer uses ClassVar type annotation, reverting to a simpler type annotation for improved type checker compatibility (1c624ff)

Upgrade instructions

  • No changes required

0.39.0 (2025-11-13)

What's changed

  • The Session model now includes a typed query class variable using ClassVar[models.QuerySet[Session]] for improved IDE autocomplete and type checking support (c3b00a6)

Upgrade instructions

  • No changes required

0.38.0 (2025-11-13)

What's changed

  • Model fields now use the new typed field syntax with explicit type annotations and types.CharField, types.JSONField, and types.DateTimeField imports (c8f40fc)

Upgrade instructions

  • No changes required

0.37.0 (2025-11-12)

What's changed

  • Type checking has been improved in SessionMiddleware with an assertion to ensure session_key exists after save() and explicit bool() conversions for cookie security flags (f4dbcef)

Upgrade instructions

  • No changes required

0.36.2 (2025-10-31)

What's changed

  • Internal package configuration updated to include BSD-3-Clause license in pyproject.toml (8477355)

Upgrade instructions

  • No changes required

0.36.1 (2025-10-29)

What's changed

  • Documentation has been expanded with a new "Session expiration" section that clarifies how session expiration works and explains the difference between SESSION_SAVE_EVERY_REQUEST = False (save only when modified) and True (rolling sessions) (3ccbbe6)

Upgrade instructions

  • No changes required

0.36.0 (2025-10-22)

What's changed

  • The SessionMiddleware now inherits from the new HttpMiddleware abstract base class and uses process_request() instead of __call__() (b960eed)
  • Type annotations have been improved throughout the middleware (77dfa66)

Upgrade instructions

  • No changes required

0.35.1 (2025-10-20)

What's changed

  • Internal package configuration updated to use [dependency-groups] instead of [tool.uv] for dev dependencies (1b43a3a)

Upgrade instructions

  • No changes required

0.35.0 (2025-10-17)

What's changed

  • The clear_expired chore has been refactored to use the new class-based Chore API, renamed to ClearExpired (c4466d3)

Upgrade instructions

  • No changes required

0.34.1 (2025-10-16)

What's changed

  • The get_current_session() template function now catches SessionNotAvailable exceptions and returns None instead of raising an error, improving error page rendering before middleware runs (fb889fa)

Upgrade instructions

  • No changes required

0.34.0 (2025-10-10)

What's changed

  • A new SessionNotAvailable exception is now raised when attempting to access a session before SessionMiddleware has run, providing clearer error messages instead of a generic KeyError (fe47d8d)

Upgrade instructions

  • No changes required

0.33.0 (2025-10-07)

What's changed

  • The Session model now uses model_options instead of an inner Meta class for model configuration (17a378d)

Upgrade instructions

  • No changes required

0.32.2 (2025-10-06)

What's changed

  • Type annotations have been added throughout the package for improved IDE support and type checking (f3a7cdd)

Upgrade instructions

  • No changes required

0.32.1 (2025-10-02)

What's changed

  • Documentation examples have been updated to reflect the new session access patterns introduced in 0.32.0 (f6278d9)

Upgrade instructions

  • No changes required

0.32.0 (2025-10-02)

What's changed

  • Session access has been refactored to use explicit functions and mixins instead of attaching directly to the request object (154ee10)
  • New get_request_session() function provides explicit access to sessions in middleware and other contexts
  • New SessionViewMixin provides convenient self.session property for class-based views
  • New get_current_session() template global function for accessing sessions in templates

Upgrade instructions

  • Replace request.session with get_request_session(request) in middleware or other non-view code
  • In class-based views, inherit from SessionViewMixin and use self.session instead of self.request.session
  • In templates, replace request.session with get_current_session() if not using views downstream of a SessionViewMixin

0.31.0 (2025-09-30)

What's changed

  • The toolbar integration has been refactored to use the new ToolbarItem API instead of ToolbarPanel, with SessionToolbarPanel renamed to SessionToolbarItem (79654db)

Upgrade instructions

  • No changes required

0.30.0 (2025-09-25)

What's changed

  • Preflight checks have been migrated to use the new class-based PreflightCheck API with unified fix messages instead of separate msg and hint fields (b0b610d, c7cde12)
  • Preflight check IDs have been renamed to use descriptive names instead of numbered codes (e.g., security.W010security.session_cookie_not_secure_app) (cd96c97)

Upgrade instructions

  • No changes required

0.29.0 (2025-09-12)

What's changed

  • Model manager API has been renamed from .objects to .query throughout the codebase (037a239)

Upgrade instructions

  • Replace any usage of Session.objects with Session.query in your code (e.g., Session.objects.filter() becomes Session.query.filter())

0.28.0 (2025-09-09)

What's changed

  • The SessionStore now exposes a model_instance property that returns the underlying Session model instance, making it easier to access session metadata like the ID (f374290)
  • Session admin interface now displays the numeric session ID instead of session keys for better readability (b3dca07)
  • OpenTelemetry tracing now uses the session ID instead of the session key for better observability (9cc458e)
  • Session toolbar display has been simplified by removing the session key display (e1fa569)
  • Minimum Python version is now 3.13 (d86e307)

Upgrade instructions

  • No changes required

0.27.0 (2025-08-27)

What's changed

  • The toolbar panel for sessions has been moved to the new plain.toolbar package. A new SessionToolbarPanel is now available in plain.sessions.toolbar (e49d54b)
  • The README has been significantly expanded with comprehensive documentation including usage examples, configuration options, and installation instructions (4ebecd1)
  • Updated the package description to "Database-backed sessions for managing user state across requests" (4ebecd1)

Upgrade instructions

  • No changes required

0.26.1 (2025-07-23)

What's changed

  • Added bootstrap icons to the Session admin interface with a "person-badge" icon (9e9f8b0)

Upgrade instructions

  • No changes required

0.26.0 (2025-07-22)

What's changed

  • Session model now uses the new PrimaryKeyField instead of BigAutoField for the primary key (4b8fa6a)

Upgrade instructions

  • No changes required

0.25.0 (2025-07-18)

What's changed

  • Session middleware now includes OpenTelemetry tracing support, automatically setting the session ID as a span attribute when available (b0224d0)

Upgrade instructions

  • No changes required

0.24.0 (2025-07-18)

What's changed

  • Migration history was consolidated into a single initial migration file. The new 0001_initial.py includes all the current schema changes without the intermediate migration steps (484f1b6).

Upgrade instructions

  • Run plain migrate --prune plainsessions to run migrations and delete old ones from the database.

0.23.0 (2025-07-07)

What's changed

  • Sessions are now stored in a brand-new Session model that uses a numeric primary key, a JSON session_data column, and a created_at timestamp. A built-in data migration copies existing rows and removes the legacy table (aec55e3).
  • SessionStore now subclasses collections.abc.MutableMapping, giving it the full standard dictionary interface (iteration, len(), update(), etc.). Redundant helpers such as has_key() were removed (493d787, 5c1ffd8).
  • Session persistence was simplified: the cryptographic signing layer was removed and data is now saved as plain JSON via update_or_create (aec55e3, 91e6540).
  • Added admin integration – a SessionAdmin viewset is registered so you can view and inspect sessions from Plain Admin under “Sessions” (aec55e3).
  • Additional internal refactors around session caching and attribute names for better readability and performance (f2beb33).

Upgrade instructions

  • Run your project’s database migrations after upgrading (plain migrate). The included migration will automatically convert existing sessions to the new schema.
  • Confirm that everything you stash in request.session is JSON-serialisable. Complex Python objects that are not JSON-encodable should be converted to primitives (for example, cast to str).
  • If you were using the deprecated has_key() helper, replace it with the standard in operator (e.g. if "foo" in request.session:).

0.22.0 (2025-06-23)

What's changed

  • Added plain.sessions.test.get_client_session helper to make it easier to read and mutate the test client’s session inside unit-tests (eb8a02).
  • Internal update for the framework’s new single-DATABASE configuration. Session persistence no longer relies on DATABASE_ROUTERS and always uses the default database connection (d346d81).

Upgrade instructions

  • If your project is already using the new single DATABASE setting, no action is required.
  • Projects that still define DATABASES and/or DATABASE_ROUTERS in settings.py must migrate to the new single DATABASE configuration before upgrading.