#21472 closed Bug (fixed)
Django 1.6 ImageField not rendered properly in Admin inline form
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | 1.6 |
Severity: | Normal | Keywords: | regression |
Cc: | agale031176@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
Hi
I have a model with ImageFields but the ImageField does not show properly when the model is an inline of another form. Downgrading to django 1.4.9 things are fine. So I think this is an issue with django 1.6.
Attachments (2)
Change History (11)
comment:1 by , 11 years ago
by , 11 years ago
Attachment: | django-1.4.9.png added |
---|
by , 11 years ago
Attachment: | django1.6.png added |
---|
comment:2 by , 11 years ago
Files attached showing the difference between 1.4.9 and 1.6. Django 1.5 is the same as 1.6. ImageFields inlines are not showing.
comment:3 by , 11 years ago
Screenshots are nice, but that's not sufficient for us to reproduce the issue to confirm it's actually a problem with Django and not your own code or a 3rd party library. Using the Choice model in the tutorial, I was able to add an inline ImageField just fine.
comment:4 by , 11 years ago
Here is the code that I have that works in 1.4.9 but not in later releases:
In the models.py:
class Property(models.Model):
property_id = models.IntegerField(primary_key=True, default=0)
title = models.CharField(max_length=250, null=False)
village = models.ForeignKey(Village, 'name')
class PropertyImages(models.Model):
property_id = models.ForeignKey(Property)
image_path = models.ImageField(null=False, upload_to='test')
Then in the admin.py:
class PropertyImagesAdmin(admin.TabularInline):
model = PropertyImages
fields = image_path
class PropertyAdmin(admin.ModelAdmin):
fields = [
'title', 'village'
]
inlines = [
PropertyImagesAdmin,
]
admin.site.register(Property, PropertyAdmin)
I am not sure if Django is the problem or I have to do this differently in later version.
comment:5 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I could reproduce and can confirm that this happens when object primary key = 0. The cause still needs to be investigated...
comment:6 by , 11 years ago
Component: | Uncategorized → Forms |
---|---|
Keywords: | regression added |
OK, so this was introduced with the fix for #19524 ([e9c24bef74e5572] and [5097d3c5faab2] (1.5)).
The problem is the test if self.instance.pk:
in BaseInlineFormSet.__init__
which should probably be if self.instance.pk is not None:
.
comment:7 by , 11 years ago
What about backpatching? This seems to be both in 1.5 and 1.6. Django 1.5 is in security fixes only mode, and this clearly isn't a regression for 1.6. The changes required here seem to be trivial, and possibility for new regressions seems really low, so I vote for backpatch to 1.6.
comment:8 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Could you provide some more details like code to reproduce, a traceback, etc. Have you tested with Django 1.5 to see if the issue exists there?