开发者

Not able to diplay images in django

Im trying to make a shopping portal with a recommendation system

Not able to display images in the templates... The HTML pages when opened without running the server opens them though tr开发者_JAVA技巧ied setting the MEDIA_URL and MEDIA_ROOT

settings as given:

MEDIA_ROOT = "/home/jose/Estore/estore/images/"
MEDIA_URL = '/images/'

The Model I defined is as given:

#Model for Books
from django.db import models

class Book(models.Model):

    title = models.CharField(max_length=100)
    section = models.CharField(max_length=50)
    authors = models.CharField(max_length=150)
    subject = models.CharField(max_length=50)
    publisher = models.CharField(max_length=50)
    publication_date = models.DateField(blank=True, null=True)
    price = models.DecimalField(max_digits=6,decimal_places=2)
    photo = models.ImageField(upload_to='product_photo/books/',blank=True)
    description = models.TextField()
    rating = models.DecimalField(max_digits=2,decimal_places=1)

    def __str__(self):
        return self.title


Have you set your urlconf?

http://docs.djangoproject.com/en/dev/howto/static-files/#serving-other-directories

here is how to do that. You need to set this in order for static serving to work.

Did this help?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜