#10002: Data does not display in TabularInline when validation fails for an
ImageField
-------------------------------------------+--------------------------------
          Reporter:  anonymous             |         Owner:  nobody             
      
            Status:  new                   |     Milestone:  1.1                
      
         Component:  django.contrib.admin  |       Version:  1.0                
      
        Resolution:                        |      Keywords:  TabularInline, 
ImageField
             Stage:  Accepted              |     Has_patch:  0                  
      
        Needs_docs:  0                     |   Needs_tests:  0                  
      
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Comment (by kmtracey):

 I can recreate a problem, not entirely sure it is exactly what was
 originally reported.  Given these models:

 {{{
 #!python
 class FCollection(models.Model):
     name = models.CharField(max_length=22)
     def __unicode__(self):
         return self.name

 class FileT(models.Model):
     coll = models.ForeignKey(FCollection)
     rating = models.IntegerField()
     ifile = models.ImageField(upload_to=u'uploaded_files')
     def __unicode__(self):
         return u'%s: %s' % (unicode(self.coll), self.ifile)
 }}}

 and this admin.py:

 {{{
 #!python
 class FileTInline(admin.TabularInline):
     model = FileT

 class FCollectionAdmin(admin.ModelAdmin):
     inlines = [FileTInline]

 admin.site.register(FCollection, FCollectionAdmin)
 }}}

 Recreate by first creating an FCollection and uploading one file.  Then,
 attempt to add a 2nd, but only fill in the rating, don't actually upload a
 file.  Upon hitting any of the save buttons, the page will get re-
 displayed with the "This field is required" and "Please correct the error
 below" messages (both fine), but also the widget for the 1st file will no
 longer show that the first inline object has an associated file.  That is,
 it will no longer have "Currently: whatever_file_name" nor the "Change:"
 label next to the file chooser input box.

 So, I see that the existing data for the already-uploaded file fields
 appears to vanish, but I'm not sure if there was more vanishing going on
 in the original report which says "wipes out all the previous data".  It's
 only the existing file field data that isn't displayed, the rest of the
 fields display properly.  Also it is just that the data is not being
 shown, it hasn't been lost: if you go back and reload the page from
 scratch or fix the required error by choosing a file to upload and saving,
 then again all of the uploaded file information is displayed on the page.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10002#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to