-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix persisting data to strings for the JSONField after a Django …
…1.9 change.
- Loading branch information
1 parent
bacd5bd
commit 919463e
Showing
1 changed file
with
9 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,9 @@ class Page(models.Model): | |
""" | ||
|
||
def to_python(self, value): | ||
""" | ||
Convert a string from the database to a Python value. | ||
""" | ||
if value == "": | ||
return None | ||
|
||
|
@@ -122,6 +125,12 @@ def to_python(self, value): | |
pass | ||
return value | ||
|
||
def get_prep_value(self, value): | ||
""" | ||
Convert the value to a string so it can be stored in the database. | ||
""" | ||
return self.get_db_prep_save(value) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
skorokithakis
Author
Owner
|
||
|
||
def from_db_value(self, value, *args, **kwargs): | ||
return self.to_python(value) | ||
|
||
|
This will trigger an error, since the get_db_prep_save method requires a second
connection
positional arg.