-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
If schema contains conint, the migrations fail with ValueError: Cannot serialize: Gt(gt=0)
from django.db.models import Model
from django_pydantic_field import SchemaField
from pydantic import conint
class WebsiteUser(Model):
test: conint(gt=0, lt=9999) = SchemaField(null=True)Then on attempt to run makemigrations:
$ ./manage.py makemigrations
Migrations for 'example':
example/migrations/0002_websiteuser_test.py
- Add field test to websiteuser
Traceback (most recent call last):
File "/home/z/pproj/django-hello-world/./manage.py", line 22, in <module>
main()
File "/home/z/pproj/django-hello-world/./manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/z/pproj/django-hello-world/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
...
File "/home/z/pproj/django-hello-world/.venv/lib/python3.10/site-packages/django_pydantic_field/compat/django.py", line 226, in serialize
attr_repr, attr_imports = serializer_factory(attr).serialize()
File "/home/z/pproj/django-hello-world/.venv/lib/python3.10/site-packages/django/db/migrations/serializer.py", line 42, in serialize
item_string, item_imports = serializer_factory(item).serialize()
File "/home/z/pproj/django-hello-world/.venv/lib/python3.10/site-packages/django/db/migrations/serializer.py", line 201, in serialize
item_string, item_imports = serializer_factory(item).serialize()
File "/home/z/pproj/django-hello-world/.venv/lib/python3.10/site-packages/django/db/migrations/serializer.py", line 378, in serializer_factory
raise ValueError(
ValueError: Cannot serialize: Gt(gt=0)
There are some values Django cannot serialize into migration files.
For more, see https://docs.djangoproject.com/en/4.1/topics/migrations/#migration-serializing
Metadata
Metadata
Assignees
Labels
No labels