Skip to content
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

fix jsonb parse after get value from database #367

Closed
wants to merge 1 commit into from

Conversation

sillydong
Copy link

In my development environment, the UserPreference will always return value as str although it is set to JSONBField.
image

I dig deeper and found the model of django needs from_db_value to do the type convert job.
image

So added this function for JSONField to support auto convert. Please kindly review this. Thanks!

VERSIONS:
Python == 3.7.10
django == 3.2.4
djangorestframework == 3.12.4
djangorestframework-bulk == 0.2
djangorestframework-filters == 1.0.0.dev2
django-admin-bootstrapped == 2.5.6
django-bootstrap3 == 11.1.0
django-filter == 2.4.0

@jdetaeye
Copy link
Member

FrePPLe needs a customized version of django 2.2: see

https://github.com/frePPLe/django/tarball/frepple_6.0

However, I see you have "django == 3.2.4".

Until we upgrade to a newer django version, I prefer not merge this pull request. With such an upgrade we'd probably migrate to django's standard jsonfield rather than keeping the current customized one.

@sillydong
Copy link
Author

@jdetaeye Thanks for your reply.

As I'm building it from source. I didn't use code from https://github.com/frePPLe/django/tarball/frepple_6.0. So the default installed version for django is 3.2.4. I'll try downgrade it.

However, this fix can be used later when you upgrade django to 3.x.x version. I guess this may still be useful.

@sillydong
Copy link
Author

Also, I'm trying the source code with django == 3.1.12, a little earlier than the latest version. If you have plan to upgrade it. I can also provide modifications for compatibility.

@jdetaeye
Copy link
Member

The correct way to install the dependencies is to install all with pip:
pip3 install -r https://raw.githubusercontent.com/frepple/frepple/6.14.0/requirements.txt
Simple and easy, and it will install the customized version of django.
You can install in a virtualenv if you don't want to mix up your default python installation.

We have no short term plans to upgrade django. Django 2.2 is an LTS release supported till next spring - see https://www.djangoproject.com/download/

If you work on upgrading django, you need to check out all our customizations on top of 2.2.17: you can see those on https://github.com/frePPLe/django/commits/frepple_6.0 These customizations are really important for frepple to work correctly.

@sillydong
Copy link
Author

Thanks a lot

1 similar comment
@sillydong
Copy link
Author

Thanks a lot

@jdetaeye
Copy link
Member

Closing this pull request. We are currently working on the upgrade from django 2.2 to django 3.2. Your pull request provided input for a part of the required code changes. Many thanks for the input!!!

@jdetaeye jdetaeye closed this Jan 31, 2022
@sillydong sillydong deleted the upstream branch May 13, 2022 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants