You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using a URLField in a Django model and then using a ModelSchema for serialization/validation on a POST request, the url is just validated as a str. Most other fields are covered in Ninja, but this one seems to be missing.
Versions (please complete the following information):
Python version: [e.g. 3.6] 3.11.9
Django version: [e.g. 4.0] 5.0
Django-Ninja version: [e.g. 0.16.2] 1.1.0
Pydantic version: [e.g. 1.9.0] 2.7.1
The text was updated successfully, but these errors were encountered:
It could be easy enough to just the annotation to the TYPES list in fields but the tricky bit is mimicking Django validator behavior. Django's default behavior is debatable too though, as it will accept FTP URLs and IPs which many people might not want.
Maybe the more complete solution is to be able to declare a Pydantic type annotation on a custom Django Field, then it could get reused automatically everywhere. It would also provide a path for third-party libraries that implement their own fields to improve their out-of-box support with Ninja.
lapinvert
added a commit
to lapinvert/django-ninja
that referenced
this issue
Aug 5, 2024
Describe the bug
When using a
URLField
in a Django model and then using aModelSchema
for serialization/validation on aPOST
request, the url is just validated as astr
. Most other fields are covered in Ninja, but this one seems to be missing.Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: