I am using django to create a website. I have spent days on an in vain inquire: I just want to display an image in my website. when I use <img src='...> the server shows a blanc page. Even when I see the source code of the home.html rendered by the server, I find a correct html code but, the image is not displayed. I will be grateful if anyone helps me because this trick took so much time. It becomes like a big stumbling bloc.
Models
from django.db import models
class img(models.Model):
title = models.CharField(max_length=200)
donnee = models.ImageField(upload_to='photos')
class snd(models.Model):
imgnd = models.ForeignKey(img)
title = models.CharField(max_length=200)
Views
from gifs.models import img
from django.shortcuts import render_to_response
def finale(request):
s=img.objects.get(id=1)
p=s.donnee
return render_to_response('home.html', {'p': p})
Template home.html
<img src='C:/Users/Me/Desktop/internship/medias/{{p}}' />
URLs
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^home', 'gifs.views.finale'),
url(r'^admin/', include(admin.site.urls)),
)

New Topic/Question
Reply



MultiQuote




|