简体   繁体   English

将典型图像加载到Django 1.3

[英]Loading a typical image to Django 1.3

I have a very basic question about adding images to Django 1.3. 关于将图像添加到Django 1.3中,我有一个非常基本的问题。

I've almost read the whole documents on adding Static files, searched for relevant results and still have a problem with my case. 我几乎已经阅读了有关添加静态文件的整个文档,搜索了相关结果,但我的案子仍然有问题。

Please take a look at my settings: 请查看我的设置:

STATIC_ROOT = '/home/vahid/Aptana3Workspace/djangoshop/djangoShop/static'

STATIC_URL = '/static/'

STATICFILES_DIRS = (STATIC_ROOT ,  )

I did the last one to avoid collision between ROOT and DIRS and make it more simple to implement the idea. 我做了最后一个,以避免ROOT和DIRS之间发生冲突,并使实现该想法更加简单。

I have also added some stuff to settings.py as: 我还为settings.py添加了一些东西:

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

INSTALLED_APPS = (.....
                               'django.contrib.staticfiles',
                               .........
                               ) 

But I still have a problem with loading the images (for example: logo.jpg) 但是我仍然无法加载图像(例如:logo.jpg)

What is a simple way to load images in the developing environment? 在开发环境中加载图像的简单方法是什么?

One extra point is that I'm developing an e-commerce project with Django 1.3, And would like to present each image besides to products' info, which is saved by "models.ImageField". 还有一点是,我正在使用Django 1.3开发一个电子商务项目,并且除了产品信息外,还希望展示每个图像,这些信息由“ models.ImageField”保存。 As you see, this is also a problem with static files. 如您所见,这也是静态文件的问题。

I am not sure if this will answer your question, but for a similar purposes I either run Apache locally to serve my media, or even point Django to the live site for the media files if the live version of my site is already up and running. 我不确定这是否可以回答您的问题,但是出于类似的目的,如果我的站点的实时版本已经启动并且正在运行,我会在本地运行Apache来为我的媒体提供服务,甚至将Django指向该媒体文件的实时站点。

I have found photologue suitable for all my image handling needs. 我发现适合我所有图像处理需求的相簿

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM