django - Display the currently saved file even when the admin does not validate the model -


to illustrate problem, consider (useless) model:

from django.core.exceptions import validationerror  def mymodel(models.model):     file = models.filefield('file')     def clean(self):         super(mymodel, self).clean()         raise validationerror('err') 

when new file selected in admin site before saving, clicking on save button returns page displays error 'err' (as expected), file field not show currently saved file of model. (i not talking new file user tries upload.)

what see this:

wrong field

while expected:

right field

the problem not occur when no new file upload selected. , when see problem, refreshing page displays file path again, still saved expected.

how can make sure saved file displayed, when raise validation error?

(django 1.9.8)


Comments