-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Added an optional USER_SESSIONS_USER_TO_FIELD setting #18
Conversation
…uration of Session.user.to_field
Running a South automatic schemamigration claims nothing has changed. |
Hmmm... South lied ): |
This gets tricky in case the field's type is changed ): |
Yes, changing the type down the project will probably have a large impact. So why do you wan't to continue using another field, which is not the primary key, while keeping the actual the primary key in place? You could use the actual primary key as well. |
The problem is that some packages, even Django itself, still consider the User's primary key to be an integer. So now the initial migration of user_sessions is problematic since it states that the User's primary key is a Seems that overriding it, e.g. with Is there a way we can at least make that part dynamic? |
You'd probably have to look into making this part dynamic. In order me to merge this pull request, your changes should not include extra configuration settings. I think it should work when you set the User's primary key to the For your other problem with Django itself, you could have a look into overriding the migrations that are created. Or patch the models altogether in your code. |
Yes, that is the part I was asking about:
I don't think there's a way making this dynamic, unless it's settings option. My only way out of this now is patching this in my own fork. If it's something you're willing to consider, please let me know and I'll work on a new PR. Thanks a million! |
I think it would work in the migrations, if you changed the relevant part to this:
Can you try to get this to work? |
I'll give it a try, thanks! Another thing I came across was that when the sessions backend is attempting to JSON-serialize the session it's breaking because the session key, i.e. the user id, isn't serializable since it's a UUID object instance. Trying to find now the cleanest way to get it cast to a string/unicode on serialization. Any idea? |
Looks like it Django isn't ready yet for this, see here. And the serialization issue is all over the web without a reasonable solution in sight. I have an idea on a different approach which I'll open in a separate thread. Thanks for all your help! |
Allowing configuration of
Session.user.to_field
.My use case: I have a field
uuid
on myAccount
model which is the actual field I'd like to reference. I can't make that field primary yet since it will break other parts of Django or other packages that expectAccount.pk
to be an integer.