I have a model like this:
class MyModel(models.Model):
name = models.CharField(max_length=255)
code = models.FileField()
When the new MyModel is introduced, I want to allow the code field to be left blank, in which case I need Django to create an empty file (with an arbitrary name).
Question: What is the right way to do this?
I could not find anything related in the documents, so I looked for manually editing request.FILES before loading it into MyModelForm (), but it looks like a dirty hack for me ... Any ideas?
Thank.
source
share