Hi,
I'm getting error messages with sorl thumbnail. I'm simply trying to show
thumbnail images on my template. I select a number of images in my views,
and iterate over my selection. Note that all my images are a certain size,
and I'm just trying to reduce that size in my template using sorl thumbnail.
All works fine, until I use the following template thumbnail tag:

<img src="{% thumbnail '{{obj}}'  80x80 %}}" />

where {{ob}} is the source directory of my image. I get the following error:

ThumbnailException: Source file:
'/home/malcolm/data1/orders1/media/{{obj}}' does not exist.


Removing quotes like this
<img src="{% thumbnail {{obj}}  80x80 %}}" />

gives me this :
Could not parse the remainder: '{{obj}}' from '{{obj}}'

Here is my model:

class Images(models.Model):
    prim = models.AutoField(primary_key=True, db_column='PRIM') # Field name
made lowercase.
    photos = models.ImageField(db_column='PHOTOS', upload_to='img',
 blank=False) # Field name made lowercase.
    items = models.CharField(max_length=255, db_column='ITEMS', blank=False)
# Field name made lowercase.
    date = models.DateField(null=True, db_column='DATE', blank=False) #
Field name made lowercase.
    updated = models.DateField(auto_now='true', db_column='UPDATED') # Field
name made lowercase.
    created = models.DateTimeField(auto_now_add='true', db_column='CREATED')
# Field name made lowercase.
    descrip = models.CharField(max_length=255, db_column='DESCRIP',
blank=True) # Field name made lowercase.
    specs = models.TextField(db_column='SPECS', blank=True) # Field name
made lowercase.
    ads = models.TextField(db_column='ADS', blank=True) # Field name made
lowercase.

    class Meta:
        db_table = u'IMAGES'
    def get_absolute_url(self):
        return "http://baglux.sporthill.com/media%s"; % self.photos
    def __unicode__(self):
        return 'img/fall09/'+self.items + '.jpg'

Here is the relevant part of my template:
<p>Total # Images all pages equals {{selected.count}}</p>
{% autopaginate selected 3 %}
{% for obj in selected %}
<table id="imag">
<tr>
<td align="center"><img id="images" src="{{ obj.get_absolute_url }}"
/></td></tr>
<tr>
<td align="center"><img src="{% thumbnail '{{obj}}'  80x80 %}}" /></td></tr>
<tr><td align="center">Item# {{obj.items}}</td></tr>
<tr><td align="center"><a href="/{{return}}/{{obj.items}} :
{{obj.descrip}}/">{{obj.descrip}}</a> </td></tr>
<tr><td align="center" style="font-size:20px; width=100px">{{obj.ads}}</td>
</tr>
</table>
{%endfor%}
{% paginate %}

Here is my view:

@login_required
def images_selected(request,  id=None):
    return_form=id
    itemz=[]
    if return_form=='clos':
        items=InventoryCloseouts.objects.all()
        for i in items:
            itemz.append(i.items)
        return_form='order_closeouts/imgs'
    if return_form=='form':
        items=Inventory.objects.all()
        for i in items:
            itemz.append(i.items)
        return_form='orders/imgs'
    selected=Images.objects.filter(items__in=itemz).order_by('pk')

    return render_to_response('images_selected.html', {'selected':selected,
'return':return_form,  }, context_instance = RequestContext(request))

In another template, all works as it should using this template tag:

<img src="{% thumbnail 'img/1656.jpg' 80x80 %}" />

In the above case, I hard code the source directory.

Any thoughts on how to correct this would be very much appreciated.
Thanks!

Malcolm

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to