How to display images from model in templates?
I will display images from photos directory (upload_to='photos') in my template index.html. How to do?
For example:
My models
class Photo(models.Model): nazwa = models.ImageField(upload_to='photos', verbose_name='My Photo') My views
def index(request): img = Photo.objects.all().order_by('-id') return render_to_response("index.html", {"img": img}) My urls
urlpatterns = patterns('', url(r'^/?$', 'album.views.index'), (r'^static/(.*)$', 'django.views.static.serve', {'document_root': os.path.join(os.path.dirname(__file__), 'static')}), ) My template, index.html
{% for n in img %} ?? {% endfor %}