I've had similar problems with using an image field as the core field
in an edit_inline relationship. When an object with an edit_inline
relationship is saved, the admin checks if the core fields on any of
th erelated objects are blank, and if so, it deletes that related
object. aWhat happens when you use an imagefield as a core field is
that every time you save the object without re-uploading the image, it
treats it as blank and removes the related image.

Core fields are going away in the magic-removal branch, so this won't
be a problem forever. In the meantime, I've found it helpful to add a
required text field (title or note caption, whatever) to the image
model and using that as the core field.

On 3/25/06, sparkydeville <[EMAIL PROTECTED]> wrote:
>
> Thank you Ivan, Law and Malcolm for the fast, and helpful replies...
> problems persist.
>
> I fixed the syntax error in the __repr__ of the Article class, and
> while I'm no longer getting "Django blowup errors", there are other
> bugs to contend with.
>
> Also, the full path to the upload directory *works* even if a relative
> path to the media folder would be better - I don't want to spend time
> fix things that aren't broken until the "showstoppers" are addressed.
>
> To clarify the use-case, consider an article like an image gallery,
> wherein one article can have more than one image associated with it.
> Further it would be helpful if the Article add/edit form could allow
> users to add images while adding / editing articles.
>
> For the sake of completeness my entire model is included this time, and
> let me say that it all "works" in the sense that it produces no
> "exceptions" during usage.
>
> The main issue I'm facing is that the "article image" upload widget(s)
> appear on the article add/edit form but the admin system doesn't know
> how to ignore these fields when the user doesn't choose images to
> upload on every article add/edit. This causes two problems:
>
> 1. submitting the article add/edit form without selecting an image for
> upload still creates a "stump" record in the db, which has no value for
> "the_image", which should be a path to the iamge. If no file was
> uploaded, I don't want it to complain either, I just want that field
> ignored if empty.
>
> 2. submitting the article edit form when images were previously
> uploaded: the result is that the previously uploaded images are deleted
> (on disk) and the records in the db are also deleted, replaced with
> more of the same empty records described in bug #1 (above).
>
> from django.core import meta
> from time import strftime
>
> class VolIssue(meta.Model):
>
>     display_id = meta.CharField('Vol/Issue', help_text='ie: 2408',
> maxlength=4, unique=True)
>     pub_date = meta.DateField()
>
>     def __repr__(self):
>         return 'Vol %s Issue %s: %s' % (self.display_id[0:2],
>                                         self.display_id[2:],
>                                         self.pub_date.strftime('%A, %B
> %d, %Y'))
>
>     class META:
>
>         admin = meta.Admin(
>
>             list_display = ('display_id','pub_date'),
>             list_filter = ['pub_date'],
>
>             )
>
> class Category(meta.Model):
>
>     category_name = meta.CharField('Article Category', maxlength=256)
>
>     def __repr__(self):
>         return self.category_name
>
>     class META:
>         admin = meta.Admin(list_display=('category_name',),)
>         verbose_name_plural = 'Categories'
>
>
> class Author(meta.Model):
>
>     author_name = meta.CharField(maxlength=256)
>
>     def __repr__(self):
>         return self.author_name
>
>     class META:
>         admin = meta.Admin(list_display=('author_name',),)
>
>
> class Article(meta.Model):
>
>     vol_issue = meta.ForeignKey(VolIssue)
>     category = meta.ForeignKey(Category)
>     author = meta.ForeignKey(Author)
>
>     article_title = meta.CharField(maxlength=512)
>     summary = meta.TextField(maxlength=1024, blank=True)
>     article_body = meta.TextField()
>
>     def __repr__(self):
>         return self.article_title
>
>     class META:
>
>         admin = meta.Admin(
>
>             list_display = ('vol_issue', 'category', 'author',
> 'article_title'),
>             list_filter = ['vol_issue'],
>
>             )
>
> class ArticleImage(meta.Model):
>
>     #article = meta.ForeignKey(Article)
>     article = meta.ForeignKey(Article, edit_inline=meta.TABULAR,
> num_in_admin=1)
>
>     image_caption = meta.CharField(maxlength=256, blank=True)
>     the_image =
> meta.ImageField(upload_to='/home/sparky/django_instances/gbtt/media/editorial_u\
> ploads/', core=True)
>
>
>
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to