Django

Code

Ticket #3567 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

Many to One Relationship w/ just ImageField()

Reported by: sheats@gmail.com Assigned to: Gulopine
Milestone: 1.0 beta Component: django.contrib.admin
Version: SVN Keywords: fs-rf-fixed
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.

Attachments

Change History

04/12/07 10:57:59 changed by Michal Chruszcz <troll@pld-linux.org>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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.

07/08/07 08:11:54 changed by SpankRock

No answer ? no djando update ?

07/15/07 10:04:04 changed by anonymous

  • owner changed from adrian to anonymous.
  • status changed from new to assigned.

12/11/07 13:43:44 changed by Gulopine

  • keywords set to fs-rf.

12/16/07 17:18:53 changed by Gulopine

  • keywords changed from fs-rf to fs-rf-fixed.

02/27/08 19:16:24 changed by jacob

  • stage changed from Unreviewed to Accepted.

06/16/08 13:28:54 changed by Gulopine

  • milestone set to 1.0 beta.

07/31/08 08:00:35 changed by Gulopine

  • owner changed from nobody to Gulopine.
  • status changed from assigned to new.

07/31/08 08:02:14 changed by Gulopine

  • status changed from new to assigned.

08/08/08 15:59:02 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(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.


Add/Change #3567 (Many to One Relationship w/ just ImageField())




Change Properties
Action