This same issue is taking up a lot of my time too. Same symptoms. I
haven't been able to come up with a solution yet, so I'm hoping
someone can shed some light on the subject.
On Sep 10, 12:18 pm, Greg <[EMAIL PROTECTED]> wrote:
> Anybody??
>
> On Sep 5, 11:59 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > Here is my modelfilethat contains a save method - When I do a assert
> > False, self.name from within my if statement in my save method I get
> > the name of the style. However, when I do a assert False, self.image
> > I get nothing. That only happens when I edit the style from within a
> > collection usingedit_inline() - Thanks for any help on trying to
> > figure out why my CharField (name) returns a value and my ImageField
> > (image) doesn't return anything when editing a style from within a
> > collection.
>
> > class Style(models.Model):
> > name = models.CharField(maxlength=200, core=True)
> > image= models.ImageField(upload_to="site_media/")
> > simage = models.ImageField(upload_to="site_media/thumbnails/",
> > editable=False)
> > mimage = models.ImageField(upload_to="site_media/thumbnails/",
> > editable=False)
> > collection = models.ForeignKey(Collection,edit_inline=models.TABULAR,
> > num_in_admin=6)
>
> > def save(self):
> > if not self.simage and not self.mimage:
> > THUMBNAIL_SIZE = (50, 50)
> > THUMBNAIL_SIZE2 = (600, 450)
> > var = self.get_image_filename()
> > var2 = var.split('\\')[1]
> > small = var.split('\\')[0] + "\\" + var2.split('.')[0] +
> > "_sm." + var2.split('.')[1]
> > medium = var.split('\\')[0] + "\\" + var2.split('.')[0] +
> > "_md." + var2.split('.')[1]
> > self.save_simage_file(small, '')
> > self.save_mimage_file(medium, '')
> > firsti =Image.open(self.get_image_filename())
> > secondi =Image.open(self.get_image_filename())
> > if firsti.mode not in ('L', 'RGB'):
> > firsti = firsti.convert('RGB')
> > if secondi.mode not in ('L', 'RGB'):
> > secondi = secondi.convert('RGB')
> > firsti.thumbnail(THUMBNAIL_SIZE,Image.ANTIALIAS)
> > secondi.thumbnail(THUMBNAIL_SIZE2,Image.ANTIALIAS)
> > firsti.save(self.get_simage_filename())
> > secondi.save(self.get_mimage_filename())
> > super(Style, self).save()
>
> > ////////////////////
>
> > Thanks for any help
>
> > On Aug 27, 1:48 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > Looking more into the problem i noticed that when I do a 'assert
> > > False, self.get_photo_filename()' I get nothing in return. When I do
> > > the same thing (withoutedit_inline) I get the the filename of the
> > >image.
>
> > > Does anybody know why when I useedit_inlinemy
> > > self.get_photo_filename statement from within my Photo save method
> > > doesn't work?
>
> > > Above is my code
>
> > > Thanks
>
> > > Greg wrote:
> > > > Hello,
> > > > I'm having a problem when I try to create thumbnails for a class that
> > > > is hasedit_inline. Here are my two models:
>
> > > > class Collection(models.Model):
> > > > name = models.CharField(maxlength=200)
> > > > collectionslug = models.SlugField(prepopulate_from=["name"])
> > > > photo = models.ImageField(upload_to='site_media/')
> > > > description = models.TextField(maxlength=1000)
> > > > manufacturer = models.ForeignKey(Manufacturer)
> > > > type = models.ForeignKey(RugType)
> > > > material = models.ForeignKey(RugMaterial)
>
> > > > class Style(models.Model):
> > > > name = models.CharField(maxlength=200, core=True)
> > > > color = models.CharField(maxlength=100)
> > > > color_cat = models.ForeignKey(ColorCategory)
> > > > image= models.ImageField(upload_to="site_media/")
> > > > simage = models.ImageField(upload_to="site_media/thumbnails/",
> > > > editable=False)
> > > > mimage = models.ImageField(upload_to="site_media/thumbnails/",
> > > > editable=False)
> > > > theslug = models.SlugField(prepopulate_from=('name',), blank=True,
> > > > editable=False)
> > > > manufacturer = models.ForeignKey(Manufacturer, blank=True,
> > > > editable=False) #Can delete
> > > > collection = models.ForeignKey(Collection,
> > > >edit_inline=models.TABULAR, num_in_admin=6)
> > > > topsellers = models.BooleanField()
> > > > newarrivals = models.BooleanField()
> > > > closeout = models.BooleanField()
> > > > manufacturer = models.ForeignKey(Manufacturer)
> > > > sandp = models.ManyToManyField(Choice, limit_choices_to =
> > > > {'choice__id': 2})
>
> > > > def save(self):
> > > > if not self.simage:
> > > > THUMBNAIL_SIZE = (50, 50)
> > > > THUMBNAIL_SIZE2 = (600, 450)
>
> > > > self.save_simage_file(self.get_image_filename(), '')
> > > > self.save_mimage_file(self.get_image_filename(), '')
>
> > > > photo =Image.open(self.get_image_filename())
> > > > photo2 =Image.open(self.get_image_filename())
>
> > > > if photo.mode not in ('L', 'RGB'):
> > > > photo = photo.convert('RGB')
>
> > > > if photo2.mode not in ('L', 'RGB'):
> > > > photo2 = photo2.convert('RGB')
> > > > photo.thumbnail(THUMBNAIL_SIZE,Image.ANTIALIAS)
> > > > photo2.thumbnail(THUMBNAIL_SIZE2,Image.ANTIALIAS)
>
> > > > photo.save(self.get_simage_filename())
> > > > photo2.save(self.get_mimage_filename())
>
> > > > super(Style, self).save()
>
> > > > /////////////
>
> > > > When I go into the Style class I can successfully create my two
> > > > thumbnail images when I save a style. However, when i display my
> > > > styles within my collection class (edit_inline) and I create a new
> > > > style and select save then I get the following error:
>
> > > > IOError at /admin/rugs/collection/2/
> > > > [Errno 2]Nosuchfileordirectory: u'c:/django/site_media\
> > > > \thumbnails________________________________
>
> > > > //////////////////////////////////
>
> > > > Can I not create thumbnails when my class isedit_inline?
>
> > > > Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---