Code Monkey home page Code Monkey logo

Comments (11)

Bouke avatar Bouke commented on June 14, 2024

Django 1.9 is a development release, which is currently not supported. Once Django 1.9 matures support will be added in this package. Feel free to submit a pull request to resolve this issue, otherwise stick with 1.8.

from django-user-sessions.

lolsborn avatar lolsborn commented on June 14, 2024

This warning is present in 1.8, the only workaround I've found is if you don't comment out 'django.contrib.sessions' under INSTALLED_APPS and just put user_sessions underneath it and things still work as expected, but I'm not sure yet what side-effects that might have.

from django-user-sessions.

GuillaumeCisco avatar GuillaumeCisco commented on June 14, 2024

As written above, you'll have a sql table created.

from django-user-sessions.

moreati avatar moreati commented on June 14, 2024

This warning is triggered because user_sessions.models imports django.contrib.sessions.models.SessionManager which is in the same module as d.c.s.models.Session. However, even if SessionManager was in another module, it uses d.c.s.db.SessionStore, which also imports d.c.s.models.Session.

The only way I could find to avoid this, is to copy/paste SessionManager into user_serssions.models, but that

  1. introduces code duplication
  2. introduces a need to do a database migration
diff --git a/user_sessions/models.py b/user_sessions/models.py
index 1f646d1..eab6dfe 100644
--- a/user_sessions/models.py
+++ b/user_sessions/models.py
@@ -1,10 +1,27 @@
 import django
 from django.conf import settings
-from django.contrib.sessions.models import SessionManager
 from django.db import models
 from django.utils.translation import ugettext_lazy as _


+class SessionManager(models.Manager):
+    use_in_migrations = True
+
+    def encode(self, session_dict):
+        """
+        Returns the given session dictionary serialized and encoded as a string.
+        """
+        return SessionStore().encode(session_dict)
+
+    def save(self, session_key, session_dict, expire_date):
+        s = self.model(session_key, self.encode(session_dict), expire_date)
+        if session_dict:
+            s.save()
+        else:
+            s.delete()  # Clear sessions with no data.
+        return s
+
+
 class Session(models.Model):
     """
     Session objects containing user session information.

from django-user-sessions.

nickfishman avatar nickfishman commented on June 14, 2024

Django 1.9 was recently released, and the above warning is now a hard error that prevents the application from starting. It would be helpful to fix this.

from django-user-sessions.

nickfishman avatar nickfishman commented on June 14, 2024

I've started making some other fixes for Django 1.9 in a fork: #48. It's still a work in progress though.

from django-user-sessions.

Bouke avatar Bouke commented on June 14, 2024

Thanks everyone, I've merged #40 and pushed additional fixes as well; available in master.

from django-user-sessions.

GuillaumeCisco avatar GuillaumeCisco commented on June 14, 2024

Thank you everyone, will this code be available as 1.3 tag?

from django-user-sessions.

Bouke avatar Bouke commented on June 14, 2024

Seeing that there are some backwards incompatible changes, it'll probably be released as a minor release (1.3 is up next).

from django-user-sessions.

GuillaumeCisco avatar GuillaumeCisco commented on June 14, 2024

Sorry for asking again.
Should we use the master branch version for our requirements files or a specific tag will be added?
1.2.1 tag?

from django-user-sessions.

Bouke avatar Bouke commented on June 14, 2024

That's entirely up to you; the master branch is under development, your mileage might vary.

from django-user-sessions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.