Opened 8 years ago

Closed 7 years ago

Last modified 4 years ago

#3567 closed (fixed)

Many to One Relationship w/ just ImageField()

Reported by: sheats@… Owned by: Gulopine
Component: contrib.admin Version: master
Severity: Keywords: fs-rf-fixed
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The following code does not act as expected in the admin.

class Property(models.Model):
address = models.CharField(maxlength=100)
	price = models.IntegerField(blank=True)
	...

	def __str__(self):
		return self.address
	
	class Admin:
		pass

class Image(models.Model):
	propertyid = models.ForeignKey(Property, edit_inline=models.STACKED, num_in_admin=5)
	image = models.ImageField(upload_to='properties/images', core=True)


If you add a couple images the first time it's fine. If you go back and edit the Property and add another image it deletes all the other images. I found that if I add another field to the Image class it seems to work correctly.

Change History (11)

comment:1 Changed 8 years ago by Michal Chruszcz <troll@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Actually, adding another field does not solve the problem. Only if there is another field _with_ core=True and that field is not of type ImageField it will work as expected.

comment:2 Changed 8 years ago by SpankRock

No answer ? no djando update ?

comment:3 Changed 8 years ago by anonymous

  • Owner changed from adrian to anonymous
  • Status changed from new to assigned

comment:4 Changed 7 years ago by Gulopine

  • Keywords fs-rf added

comment:5 Changed 7 years ago by Gulopine

  • Keywords fs-rf-fixed added; fs-rf removed

comment:6 Changed 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:7 Changed 7 years ago by Gulopine

  • milestone set to 1.0 beta

comment:8 Changed 7 years ago by Gulopine

  • Owner changed from nobody to Gulopine
  • Status changed from assigned to new

comment:9 Changed 7 years ago by Gulopine

  • Status changed from new to assigned

comment:10 Changed 7 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [8244]) File storage refactoring, adding far more flexibility to Django's file handling. The new files.txt document has details of the new features.

This is a backwards-incompatible change; consult BackwardsIncompatibleChanges for details.

Fixes #3567, #3621, #4345, #5361, #5655, #7415.

Many thanks to Marty Alchin who did the vast majority of this work.

comment:11 Changed 4 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

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