https://docs.djangoproject.com/en/1.9/topics/http/sessions/#example
from django.contrib.sessions.backends.db import SessionStore as DBStorefrom
django.contrib.sessions.base_session import AbstractBaseSessionfrom django.db
import models
class CustomSession(AbstractBaseSession):
account_id = models.IntegerField(null=True, db_index=True)
class Meta:
app_label = 'mysessions'
@classmethod
def get_session_store_class(cls):
return SessionStore
class SessionStore(DBStore):
@classmethod
def get_model_class(cls):
return CustomSession
def create_model_instance(self, data):
obj = super(SessionStore, self).create_model_instance(data)
try:
account_id = int(data.get('_auth_user_id'))
except (ValueError, TypeError):
account_id = None
obj.account_id = account_id
return obj
In settings registered as next:
SESSION_ENGINE = 'apps.app_sessions.backends.extended_session_store'
When I made attempt create migrations, Django - silent
In [6]: !./manage.py makemigrations
No changes detected
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/66583aa8-0e69-4590-9420-6db734267ec6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.