Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21472 closed Bug (fixed)

Django 1.6 ImageField not rendered properly in Admin inline form

Reported by: agale031176@… 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)

django-1.4.9.png (109.4 KB ) - added by anonymous 11 years ago.
django1.6.png (85.9 KB ) - added by anonymous 11 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by Tim Graham, 11 years ago

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?

by anonymous, 11 years ago

Attachment: django-1.4.9.png added

by anonymous, 11 years ago

Attachment: django1.6.png added

comment:2 by anonymous, 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 Tim Graham, 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 anonymous, 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.

Version 0, edited 11 years ago by anonymous (next)

comment:5 by Claude Paroz, 11 years ago

Triage Stage: UnreviewedAccepted

I could reproduce and can confirm that this happens when object primary key = 0. The cause still needs to be investigated...

comment:6 by Claude Paroz, 11 years ago

Component: UncategorizedForms
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 Anssi Kääriäinen, 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 Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In fafb6cf049bb9f4591a8b94cffda12c081cd096f:

Fixed #21472 -- Fixed inline formsets display when parent pk is 0

Thanks agale031176@… for the report.

comment:9 by Claude Paroz <claude@…>, 11 years ago

In d8fdee7db877e3a52a761bfcbeb3536ea219ec30:

[1.6.x] Fixed #21472 -- Fixed inline formsets display when parent pk is 0

Thanks agale031176@… for the report.
Backport of fafb6cf049b from master.

Note: See TracTickets for help on using tickets.
Back to Top