On 6 авг, 18:48, Shawn Milochik <sh...@milochik.com> wrote:
> Are you running collectstatic after making those changes?
After Your advice I did so without any success. The details are:
I use django 1.3, Windows on a local computer.
1) I removed 'products' and 'thumbnails' subfolders from 'image'
folder and placed an image file directly into 'image' folder.
I changed 'index.html': <img src="{{ STATIC_URL }}images/
java_piano.jpg" />
2) settings.py contains:
STATIC_ROOT = os.path.join(CURRENT_PATH, 'static')
STATIC_URL = '/static/'
# all my static files are in static subfolder of project folder, so I
don't neet to collect them from different places into unique folder:
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
INSTALLED_APPS = (
...
    'django.contrib.staticfiles',
)
# I inserted this on Stuart MacKay advice:
# this allows you to use {{ STATIC_URL }} in your templates
TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.static',
# the next is nesessary to prevent error:
    'django.contrib.auth.context_processors.auth',
)

3) urls.py contains:
if settings.DEBUG:
    urlpatterns += patterns('django.views.staticfiles.views',
        url(r'^static/(?P<path>.*)$', 'serve'),
    )
    urlpatterns += staticfiles_urlpatterns()

4) Then I ran command:
manage.py collectstatic
It created 'admin' subfolder into 'static' folder in my project and
copied 78 files from django into it.
Now I have such folder structure:

teststatic (project folder)
L templates
   L index.html
L static
   L admin
   L images
      L java_piano.jpg

Browser sees: <img src="/static/images/java_piano.jpg"> and does NOT
load the image.
In addition, I got such error message:
Unhandled exception in thread started by <bound method
Command.inner_run of
<django.contrib.staticfiles.management.commands.runserver.Command
object at 0x01D0B530>>
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\django\core\management\commands
\runserver.py", line 107, in inner_run
This error message is prevented by removing
TEMPLATE_CONTEXT_PROCESSORS statement from settings.py.

Maybe I must place image files into an application/static folder? I
moved static/images/java_piano.jpg into an application folder:
teststatic (project folder)
L catalog (application folder)
   L static
       L images
           L java_piano.jpg
L templates
   L index.html
L static
   L admin
and ran: manage.py collectstatic again. It created a subfolder
'images' in 'teststatic/static/' and copyed the image file into it:
teststatic (project folder)
L catalog (application folder)
   L static
       L images
           L java_piano.jpg
L templates
   L index.html
L static
   L admin
   L images
       L java_piano.jpg

It HELPED :) but I still don't understand how :(. Is a key to force
staticfiles application to copy static files, and if static files are
in place then static files application doesn't change its setup?
Are all the statements I inserted into urls.py and settings.py
nesessary or some of them are not?



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to