strawberry-django
strawberry-django copied to clipboard
When the optional file field is used, an error will be reported when there are empty files in the query set
Error is thrown from here https://github.com/django/django/blob/475cffd1d64c690cdad16ede4d5e81985738ceb4/django/db/models/fields/files.py#L40
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
I avoid it like this
from django.db.models.fields import files
class FieldFile(files.FieldFile):
def _require_file(self):
pass
class FileField(files.FileField):
attr_class = FieldFile
class ImageFieldFile(files.ImageFieldFile):
def _require_file(self):
pass
class ImageField(files.ImageField):
attr_class = ImageFieldFile
Is there a more elegant way?
I avoid it like this
from django.db.models.fields import files class FieldFile(files.FieldFile): def _require_file(self): pass class FileField(files.FileField): attr_class = FieldFile class ImageFieldFile(files.ImageFieldFile): def _require_file(self): pass class ImageField(files.ImageField): attr_class = ImageFieldFile
A more elegant way:
from django.db.models.fields.files import FieldFile
FieldFile._require_file = lambda self: None # type:ignore[attr-defined]
any fix for this? ) same issue: https://github.com/strawberry-graphql/strawberry-graphql-django/issues/22