Hi,
I have a model with a FileField which is shown below. I use this model in a model form.
receipt = models.FileField(upload_to='receipt/%m-%Y/', max_length=255)
I can save the object and the receipt field contains the file url.
Now when I present this object with the model form the file url is not presented, instead a message "no file chosen" is presented.
This is the html template I m using for the form:
<table cellspacing="5">
{{ cash_expenditure_form.as_table }}
</table>
and the form that I'm using:
class CashExpenditureForm(forms.ModelForm):
class Meta:
model = CashExpenditure
exclude = ('project','paid', 'paid_check','invoice','cash_expenditure_selection')
When I check this object in the admin the field url is presented as expected. Thus I think something is missing in the html form template.
Solution:
AdminFileWidget does the trick ;-) easy as always..