0👍
As it is now, a file is required. Are you trying to save the form without a file?
If you want to make the file optional, you need to define it in this way:
class Document(models.Model):
file = models.FileField(upload_to="documents", blank=True, null=True)
As a an additional note, the action parameter you have in the form may be incorrect.
It should be an URL; usually in Django you would want to put "."
, but not a completely empty string (""
). That said, I do not know if this may be an issue or not.
👤rob
0👍
In you Document model, you have your file set to upload_t0 “documents”, but where exactly is upload_to pointed to.
- [Django]-Django Model API reverse lookup of many to many relationship through intermediary table
- [Django]-CSRF verification failed after adding a filefield on model
Source:stackexchange.com