Just started with Django myself.  Went thru 3 different tutorials.
Hopefully, what I'm mentioning below hasn't already been covered.

On Fri, 2008-02-08 at 10:34 -0800, Brandon Taylor wrote:
> So, chin up, moving on. Here is my website's directory structure:
> 
> /mysite
>   /public
>     /images
>     /css
>     /javascripts
> 
>   /templates
>     public.html
>     home_page.html
> 
> views.py
> settings.py
> urls.py
> __init__.py

>From your directory structure, it looks like views.py, settings.py,
urls.py, and __init__.py are NOT in 'mysite' but at the same level.  If
that's true, that's one reason why mod_python can't find
"mysite.settings".

I run Apache using virtual servers, so my <Location>...</Location> stuff
is associated with a specific virtual server (in httpd-vhosts.conf).  If
you don't, you can put it into the top-level httpd.conf file.  Mine
looks like this:

    <Location "/wise2/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        PythonInterpreter wise
        PythonPath "['/home/adam/Src/WISE-2.0'] + sys.path"
        SetEnv DJANGO_SETTINGS_MODULE WebSite.settings
        SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs
        PythonDebug On
    </Location>

I have everything at http://my-server/wise2/ and under handled by
mod_python.  The two main things here are PythonPath and
DJANGO_SETTINGS_MODULE.

Given your structure above, settings.py (along with views.py, urls.py,
and __init__.py) should be in the 'mysite' directory.  Then PythonPath
would be set to point to the directory 'mysite' is in:

        PythonPath "['/my/dir'] + sys.path"

In this case, your 'mysite' directory can be found at "/my/dir/mysite".
Then DJANGO_SETTINGS_MODULE would point to the settings file via the
Python import syntax:

        SetEnv DJANGO_SETTINGS_MODULE mysite.settings

mod_python would find the settings.py file because it would be in the
'mysite' directory.

> 
> When I start up the dev server using manage.py runserver, my
> home_page.html template will render, but no images, no css, etc.
> 
> How can I:
> 
> 1. Tell the development server what the root of the website is.
> 2. Where my images, css and javascript files are.
> 
> I have put: (r'^public/../(?P<path>.*)$', 'django.views.static.serve',
> {'document_root': '/public/../images'}),
> 
> in my URLconf, but, it's still not happy.

I set up to handle static content if running in DEBUG mode (i.e. theff
# Set up to server static files if running within the development
# environment
if settings.DEBUG == True:
    urlpatterns += patterns('django.views.static',
        (r'^(?P<path>.*)$', "serve", {"document_root":
"/project/www/htdocs/WISE
",}),
    )

This goes last in urls.py and will pick up anything not matched by a
real Django pattern match (i.e. everything that's NOT a Django page).
So if I have a URL like "<img src="/img/icons/UnknownPerson.jpg">, the
dev server will actually serve (given my example)
"/project/www/htdocs/WISE/img/icons/UnknownPerson.jpg" from the local
filesystem.
-- 
Adam Stein @ Xerox Corporation       Email: [EMAIL PROTECTED]
                                            
Disclaimer: All views expressed             
here have been proved to be my own.  [http://www.csh.rit.edu/~adam/]


--~--~---------~--~----~------------~-------~--~----~
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