Brandon Taylor wrote:
> Hi everyone,
> 
> I'm just about to give up on Django. I can't even get it to load a
> simple jpeg using the built-in server.
> 
> Here is my directory structure:
> 
> '/Users/bt/django_projects' is where all of my Django projects exist
> 
> /btaylor_design
> settings.py, etc
>     /public
>         /images
>         /stylesheets
>         /javascript
> 
> 
> In my urls.py, I have the following:
> 
> from django.conf.urls.defaults import *
> from django.conf import settings
> from btaylor_design.views import home
> 
> urlpatterns = patterns('',
>     (r'', home),
> 
>     # Uncomment this for admin:
>     #(r'^admin/', include('django.contrib.admin.urls')),
> )
> 
> if settings.DEBUG:
>     urlpatterns += patterns('django.views',
>                             (r'^public/(.*)$', 'static.serve',
> {'document_root': '/Users/bt/django_projects/btaylor_design/public'}),
>     )
> 
> 
> Can ANYONE give me a definitive answer on why this thing won't load so
> much as a simple image, with a src set to: <img src="/public/images/
> some_image.jpg /> ???!!!
> 
> Many thanks in advance to any kind soul who would take the time to
> help me. I've struggled with this thing, trying many variations from
> posts from this group for a couple of days, so it's not as if I'm just
> throwing my hands up at the first error. I've been doing web for a
> long time, and see a lot of promise in this framework - if I can get
> it to work!

Brandon,

I'm a total noob to Django (about two weeks of an hour here and there) 
but I haven't had anywhere near the problems you're having...

because I FOLLOWED THE DIRECTIONS.

Took me 5 seconds of googling to find the answer to your question:

http://www.google.com/search?hl=en&client=firefox-a&channel=s&rls=org.mozilla%3Aen-US%3Aofficial&hs=sTX&q=django+static+files+development+server&btnG=Search

http://www.djangoproject.com/documentation/static_files/

You have the document root thing set to public rather than 
public/images. The instructions clearly say '/path/to/media', not 
/path/to/doc/root

here's mine:

if settings.DEBUG:
     urlpatterns += patterns('',
         (r'^images/(?P<path>.*)$', 'django.views.static.serve',
          {'document_root': 'c:/projects/djcode/reports/images'}),
         (r'^css/(?P<path>.*)$', 'django.views.static.serve',
          {'document_root': 'c:/projects/djcode/reports/css'}),
     )

This isn't hard, but helps when you get started to follow the directions 
*exactly* until it's working, then try customizing things to suit your 
needs/tastes.


Michael

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to