Opened 13 months ago

Last modified 12 months ago

#22986 new New feature

Allow disabling session model database table creation if not used by session engine

Reported by: timo Owned by: nobody
Component: contrib.sessions Version: master
Severity: Normal Keywords:
Cc: chris.jerdonek@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Previously, we recommended removing contrib.sessions from INSTALLED_APPS but this causes the test client login to break (#22934) and also disables the clearsessions management command which could be useful for the file-based sessions (which also don't require the database tables).

Change History (6)

comment:1 Changed 13 months ago by Tim Graham <timograham@…>

In 3a85aae2eacae836e2a92de77615569883b81932:

Revert "Improve cookie based session backend docs." refs #20418

This reverts commit d9c01da1f8ba3d4e0947fd1d619c8f4a9b013360.

This is poor advice as it breaks the test client login (refs #22934).
We can add a note like this back after refs #22986 is resolved.

comment:2 Changed 13 months ago by cjerdonek

  • Cc chris.jerdonek@… added

comment:3 Changed 13 months ago by Tim Graham <timograham@…>

In a3d710a38f1fab5e092cef7a17826674a00e70ea:

[1.7.x] Revert "Improve cookie based session backend docs." refs #20418

This reverts commit d9c01da1f8ba3d4e0947fd1d619c8f4a9b013360.

This is poor advice as it breaks the test client login (refs #22934).
We can add a note like this back after refs #22986 is resolved.

Backport of 3a85aae2ea from master

comment:4 Changed 13 months ago by Tim Graham <timograham@…>

In f3bdb83ba58a696c0696d8a6706d2c44a00da68a:

[1.6.x] Revert "Improve cookie based session backend docs." refs #20418

This reverts commit d9c01da1f8ba3d4e0947fd1d619c8f4a9b013360.

This is poor advice as it breaks the test client login (refs #22934).
We can add a note like this back after refs #22986 is resolved.

Backport of 3a85aae2ea from master

comment:5 Changed 12 months ago by slurms

  • Has patch set
  • Needs documentation set
  • Needs tests set
  • Patch needs improvement set

I was going to tackle this, and thought that maybe we could abuse _meta.swappable, but it appears that ModelBase._check_swappable actually checks that the swappable model exists.

I wonder if this would be a use-case for the app registry to allow unregistering models? Then in the session app config's ready() we could conditionally unregister the Session model if the session engine doesn't require it.

My approach was to override AppConfig.get_model and AppConfig.get_models as a way to "disable" the session model. Unfortunately this doesn't work for migrations.

PR here: https://github.com/django/django/pull/2960

comment:6 Changed 12 months ago by cjerdonek

I haven't looked into the history of this, but it seems like one of the issues is that INSTALLED_APPS is currently being used for two different but related purposes: 1) to say which apps are being used, and 2) to say what models need to be added to the schema. I wonder what would be the best way to make this distinction.

Note: See TracTickets for help on using tickets.
Back to Top