Closed yergom closed 9 months ago
Hi @yergom ,
You mean, a field with blank=False
should fail the validation if no file upload has been provided to it?
Hi @bellini666, no, that's not the case. Let me elaborate.
If you have a field with a non optional file
class MyModel(models.Model):
file = models.FileField(null=False, blank=False)
then the validation fails. The problem is that the prepare_create_update
method is not setting the file field in the dummy instance.
That's an interesting observation @yergom. I seem to remember that I refactored the update and create methodes with prepare_create_update. This was done in order to ensure that creates and updates would respect the manager configurations.
@bellini666 I've added a PR with some tests that should cover this issue. https://github.com/strawberry-graphql/strawberry-graphql-django/pull/469
Follow up from #461. The PR https://github.com/strawberry-graphql/strawberry-graphql-django/pull/464 has solved saving the instance, but the validation code is still incorrect. FileFields with blank=False will fail validation.
Upvote & Fund