Sunday, July 31, 2011

Re: jquery

Thank You! Now I see I don't understand how can I use static files
using the development server. I saw several answers to this question
of other people but they are too breaf for me.
Books on Django I have don't explain this problem. Be so kind to
explain me.
My local computer has Windows. The project folder is c:/djangomysites/
testjquery, it contains subfolders static and templates, static
contains subfolders images and js.
Today I changed Django 1.2.3 to Django 1.3. May I consider images for
simplicity. For the same reason I don't use os function here.

settings.py contains:
STATICFILES_DIRS = (
'c:/djangomysites/testjquery/static',
)
STATIC_ROOT=''
STATIC_URL='/static/'

urls.py contains:
urlpatterns = patterns('',
(r'^', 'testjquery.views.first'),
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{ 'document_root': 'c:/djangomysites/testjquery/static' })

views.py contains:
def first(request):
return render_to_response('index.html',
context_instance=RequestContext(request))

index.html contains:
<img src="{{ STATIC_URL }}images/picture.png">
As a result, I get <img src="/static/images/picture.png"> in the
produced html-file. But the image file can't be loaded.
Thank You very much!

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment