2011年03月29日 星期二 21:56
hi,guys
我使用photologue时候,上传了图片到分类以后,点击图片连接http://127.0.0.1:8000/admin/photologue/photo/2/photologue/photos/1.jpg/
显示photo object with primary key u'2/photologue/photos/1.jpg' does not exist.
是不是我的配置有问题?
2011年03月29日 星期二 23:37
这个问题找到答案还真不容易啊,在google groups知道作者对此问题的解释,如下:
问:I'm running the photologue with Django's built in server and I don't
see any images. All the images are broken. Do you know what can be the
problem?
答:
Empty strings will not work for your MEDIA_URL, MEDIA_ROOT settings. This is
the most common mistake when setting up Django with Photologue. Here's a
quick primer but is no substitute for reading the docs.
The MEDIA_ROOT setting should be the full path to the folder you want media
files saved to (i.e. css files, javascript files, images). On windows this
might be:
"C:\mydjangoproject\media\"
In OS X / Linux:
"/home/justin/projects/mydjangoproject/media/"
The MEDIA_URL setting is the URL where these media files can be accessed
publicly. This is up to you to set up. During development I would recommend
the following:
MEDIA_URL = '/static/'
And then in your project's urls.py file add the following:
{{{
from django.conf import settings
urlpatterns = patterns('',
# All your other url patterns go here. Just add the next line:
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root':
settings.MEDIA_ROOT, 'show_indexes': True}),
)
Be sure to read up on the documentation at the Django site. It may take a
bit for some things to click but your life will be much easier if you get
familiar with the docs and how they are laid out ASAP.
我引用一句提问者的最后的回答“It magically worked!”,其实我也很惊奇,它真的好用了,django的文档有点不健全啊,期待说明文档能再做得好一点。
最近才研究web方面的,可能这个问题很简单,希望能给我和我遇到一样问题的人一点启发吧。。。。
收工睡觉了
Zeuux © 2024
京ICP备05028076号