Data does not display in TabularInline when validation fails for an ImageField
|Reported by:||anonymous||Owned by:||David Gouldin|
|Cc:||dgouldin@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a TabularInline form associated with a model in my admin and it has an ImageField and a CharField. When I edit / add a record to the list and do not upload an image, Click save and edit, it throws an error "This field is required" and wipes out all of the previous data (the data is not lost, it just doesn't appear in the list).
class Example(models.Model): name = models.CharField(max_length=128) test = models.ForeignKey(Test, related_name="examples") image = models.ImageField(upload_to=settings.UPLOAD_TO)
class ExampleInline(admin.TabularInline): model = Example class TestAdmin(admin.ModelAdmin): inlines = [ExampleInline,] admin.site.register(Test, TestAdmin)