in models.py
class Input(models.Model):
inputid = models.CharField(verbose_name='入库单号', max_length=30)
inputdate = models.DateField(verbose_name='入库日期')
hetongid = models.CharField(verbose_name='合同编号', max_length=30)
chandi = models.ForeignKey(Chandi, verbose_name='产地')
name = models.CharField(verbose_name='商品名称', max_length=100)
year = models.IntegerField(verbose_name='年份')
keyid = models.CharField(verbose_name='箱序列号', max_length=20)
bizhong = models.ForeignKey(Bizhong, verbose_name='币种')
money = models.FloatField(verbose_name='金额'))
input_pic = models.ImageField(upload_to='input_pic/')
in settings.py
HERE = os.path.dirname(os.path.abspath(__file__))
MEDIA_ROOT = os.path.join(HERE,'media').replace('\\','/')+'/'
MEDIA_URL = '/media/'
用admin后台上传图片后..
mysql数据库的input_pic值为:
input_pic/85144-340070694_l.jpg
但是在浏览器中访问如下地址不成功:
http://127.0.0.1:8000/media/input_pic/85144-340070694_l.jpg
提示:
Using the URLconf defined in ceshi.urls, Django tried these URL patterns, in this order:
^admin/
The current URL, media/input_pic/85144-340070694_l.jpg, didn't match any of these.
请问是怎么回事儿?