I have the following code that fails to display object images. But
displays normal images fine.

My Model

class News(models.Model):
title-----------
image = models.ImageField(upload_to='images')
body------------

Template tag coding

from django import template
register = template.Library()
from ----.models import ---

def funct(num):
myobjects = News.objects.all()[:num]
return {'objects': myobjects}
register.inclusion_tag('news/template.html')(funct)

template coding

{% for object in objects %}
<li>{{ object.title }}</li>
<li><img src="{{ MEDIA_URL }}images/{{ object.image }}" alt="image" /
></li>
<li>{{ object.body }}</p></li>
{% endfor %}

This code outputs all the variable information such as title and body
in a list however it does not display the associated image. I have
tried numerous variations on this code with no success. This is
strange because when an image is called from the image folder in the
following manner

<img src="{{ MEDIA_URL }}images/star.jpg" />

Everything works fine. The problems occur when its a model image being
called. Any help fixing this issue is much appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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