> On Sun, Apr 13, 2008 at 8:34 AM, Manuel Meyer > <[EMAIL PROTECTED]> wrote: > > > No, that's they way it is documented as working. The one-to-one > > field acts as the primary key for the model, and primary keys can't > > be edited. From http://www.djangoproject.com/documentation/model- > > api/#one-to-one-relationships: > > > > This OneToOneField will actually replace the primary key id field > > (since one-to-one relations share the same primary key), and will > > be displayed as a read-only field when you edit an object in the > > admin interface: > Oh, I definitely missed that :) > > But: > > now I tried this: > > item = models.ForeignKey(Article, edit_inline=models.TABULAR, > num_in_admin=1, max_num_in_admin=1 ) > > in HeaderImage. Now each time some field of Article is changed, a > assigned HeaderImage is deleted. > I doubt, that this is a feature too. > But what is wrong now? > > Sounds like: > > http://code.djangoproject.com/ticket/2413 > > In short, inline edited objects with FileFields (or ImageFields) > have some problems in the old admin. I believe these problems are > fixed in newforms-admin, so you might want to try using that branch > for your case. > > Karen
If I add a save(), it seems to work: class HeaderImage(models.Model): """ A HeaderImage of an Article. """ picture = models.ImageField(null=True, upload_to='./ images/',core=True) item = models.ForeignKey(Article, edit_inline=models.TABULAR, max_num_in_admin=1) remove = models.BooleanField(default=False) def __unicode__(self): return self.picture def save(self): super(CategoryImage,self).save() if self.remove: self.delete() def delete(self): if not self.picture==None and not self.picture=='': basename, format = self.picture.rsplit('.', 1) miniature_folder = os.path.join(s.MEDIA_ROOT, basename +'/') if os.path.exists(miniature_folder): dir = os.getcwd() os.chdir(miniature_folder) listdir=os.listdir(miniature_folder) for i in listdir: os.remove(i) os.chdir(dir) os.removedirs(miniature_folder) super(HeaderImage,self).delete() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---