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 (without edit_inline) I get the the filename of the image.
Does anybody know why when I use edit_inline my 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 has edit_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] No such file or directory: u'c:/django/site_media\ > \thumbnails________________________________ > > ////////////////////////////////// > > Can I not create thumbnails when my class is edit_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 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 -~----------~----~----~----~------~----~------~--~---