-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
AbstractBaseSession
: Use model fields for subclassed cases
#2180
AbstractBaseSession
: Use model fields for subclassed cases
#2180
Conversation
43caa11
to
a085728
Compare
a2c020b
to
ead98c8
Compare
In situations where these fields are overridden in custom models, for instance extending 'session_key`'s `max_length`. Follow a similar style to `AuthBaseUser`. See also: - https://docs.djangoproject.com/en/5.0/topics/http/sessions/#extending-database-backed-session-engines - https://github.com/django/django/blob/5.0.6/django/contrib/sessions/base_session.py - https://github.com/typeddjango/django-stubs/blob/5.0.0/django-stubs/contrib/sessions/base_session.pyi#L13-L21
Co-authored-by: Marti Raudsepp <[email protected]>
3dcaf71
to
6cbe46c
Compare
Yeah, do whatever is quickest. The commits will be squashed on merge anyway. |
b44dcc4
to
da0fad5
Compare
da0fad5
to
ae795ce
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.
Nice work. Thank you!
Maybe I spoke too soon. @intgr Is this solution fine with you? |
I'll merge this in the meantime. Lets circle back if we figure out that there's anything more that needs to be done. |
session_key = models.CharField(primary_key=True) | ||
session_data = models.TextField() | ||
expire_date = models.DateTimeField() | ||
objects: ClassVar[BaseSessionManager[Self]] |
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.
Yep this is better because it's more precise, thanks.
Changes
AbstractBaseSession
fieldsThese currently raise on mypy when overridden, such as by overriding
max_length
, see example in #2179.In situations where these fields are overridden in custom models, for instance extending 'session_key
's
max_length. Follow a similar style to
AbstractBaseUser` (django: 5.0.6, django-stubs: 5.0.0).See also:
Related issues
AbstractBaseSession
subclassing: Fields not overridable #2179