-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
add support for django 3.1 JSONField #85
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @xi thanks for your PR!!! The code looks great but can I ask you for 2 improvements:
-
Can you fix the error raised by CI?
-
Can you add an unit test to ensure support for Django's
JSONField
? It should be very similar to the existing one for postgres'JSONField
implementation.
If you have any questions, don't hesitate on pinging me for help =)
8d56ec4
to
401bc99
Compare
Unfortunately I was not able to figure out what I need to change. The output only says that black would reformat a file, but not what it would change about that file. Running black locally did not result in the message.
I pushed a test. I could not figure out how to run the tests locally so I am waiting for the results from CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xi for updating your PR!!! It was very useful no only because of the changes you're introducing, but also because it exposed for us a gap in our docs when it comes to code contributions (running tests, link, etc). We've opened #86 so future contributors won't have the same problems you had.
I think there are a few things preventing us from merging your PR:
- Wait for Improve contributing instructions and utilitaries #86 to be merged so we can rely on the
make lint
command or thepre-commit
hooks to make sure the code format is right; - Updates to the
CHANGELOG.md
; - Wait for the official Django 3.1 release to go live. For now it's still under the alpha version. Once we have it released, we'll be able to easily configure our
tox.ini
by adding thedjango31
dependency;
Thanks a lot!
401bc99
to
1825192
Compare
done
Why wait? The change should be fully backwards compatible. (I am fine if you prefer waiting, I just wanted to make sure there is no misunderstanding) |
1825192
to
7787ecb
Compare
7787ecb
to
234f90a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xi I actually forgot to mention we were waiting to release the new 1.1.1 version.
Now I'm good with merging this in. @anapaulagomes or @amureki can take a look as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I think I made a mistake when rebasing and the changelog entry is now in the wrong release (1.1.1). I won't be able to fix it until monday so maybe someone else could do it. |
Hi,
also in baker.generators i've saw that: try:
from django.contrib.postgres.fields import JSONField
except ImportError:
JSONField = None |
Hi @snicoletbcg. This patch is not yet included in 1.1.1. You will have to wait for the next release. In the meantime you could use this workaround: from django.contrib.postgres.fields import JSONField as PostgresJSONField
from django.db.models import JSONField
from model_bakery import baker
baker.generators.add(
JSONField, baker.generators.default_mapping[PostgresJSONField]
) |
Hi @xi ,
into my and then poetry update it worked fine, thank you again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have suggested an import fixing at #106
@@ -89,7 +89,16 @@ class Person(models.Model): | |||
id_document = models.CharField(unique=True, max_length=10) | |||
|
|||
try: | |||
from django.contrib.postgres.fields import ArrayField, HStoreField, JSONField | |||
from django.models import JSONField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the correct import is django.db.models
, isn't it?
@@ -19,14 +19,19 @@ | |||
from model_bakery.random_gen import gen_related | |||
from tests.generic import generators, models | |||
|
|||
try: | |||
from django.models import JSONField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the correct import is django.db.models
, isn't it?
see https://docs.djangoproject.com/en/3.1/releases/3.1/#jsonfield-for-all-supported-database-backends