Django FileField default file
问题 I have a model which contains FileField as below class Employer(models.Model): logo = models.FileField(storage=FileSystemStorage(location=settings.MEDIA_ROOT), upload_to='logos') The question is how can I add a default file like "{{ MEDIA_ROOT}}/logos/anonymous.jpg" to this filefield ? 回答1: You can specify the default file to use for that field as follows: class Employer(models.Model): logo = models.FileField(storage=FileSystemStorage(location=settings.MEDIA_ROOT), upload_to='logos', default=