django server tree organization

16 views
Skip to first unread message

Guillermo Fernandez Castellanos

unread,
Jul 30, 2006, 4:15:46 PM7/30/06
to django...@googlegroups.com
Hi,

I've seen this subject several times in the mailing lists without
being able to find a definite/useful answer in the mailing list.

I'm going to have a server with several domain names serve a few
applications (blog, photo gallery,...). But I'm a bit at a loss when
dealing with how to organize the different files.

In Django there's a separation between templates, media, applications,
the sites urls.py,... The question is, what is the
suggested/official/best practices way of managing a server with
several sites? Same for keeping an svn tree.

Do you organize it like:
/templates/site1
/site2
/media/site1
/site2
/urls/site1
/site2
/apps/app1
/app2
/app3

Or more like:
/site1/templates
/media
/urls.py
/site2/templates
/media
/urls.py

Or maybe another way?

Same for svn (maybe for svn it makes more sense the second model...).

Thanks a lot,

G

marr...@gmail.com

unread,
Jul 31, 2006, 1:17:22 AM7/31/06
to Django users

Guillermo Fernandez Castellanos wrote:
> Hi,
>
of course ,the second model is better,the first one is too much
confused

Guillermo Fernandez Castellanos

unread,
Jul 31, 2006, 4:25:15 AM7/31/06
to django...@googlegroups.com
Thanks.

But afterwards, with the second model, how can you integrate it for a
webpage to work?

Imagine a webpage that uses several distinct applications, each one
with different templates, media,... In the webserver you will still
have only one template subdirectory and one media subdirectory. How
will you integrate all this?

Thanks,

G

Miguel Hernández

unread,
Jul 31, 2006, 8:32:31 AM7/31/06
to django...@googlegroups.com
Hi,


On 7/30/06, Guillermo Fernandez Castellanos <guillermo.ferna...@gmail.com > wrote:

>    I'm going to have a server with several domain names serve a few
>    applications (blog, photo gallery,...). But I'm a bit at a loss when
>    dealing with how to organize the different files.

I prefer your second solution, with modifications. I like the idea of self-contained reusable applications to simplify deploying dependencies. At work we try to separate projects from sites using this layout:

Starting at /home/work/django

media/
    (common media files and folders)
    (soft links to real media folders)
templates/
    (common templates)
apps/
    blog/
        media/
        templates/
    photogallery/
        media/
        templates/
sites/
    site1/
        config/
            settings.py
            urls.py
            manage.py
    site2/
        config/
            settings.py
            urls.py
            manage.py

site1 vhost config is as follows (using apache 2.0 and mod_python)
<VirtualHost *:80>
    ServerName site1
    <Location "/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE config.settings
        PythonPath "['/home/work/django/apps', '/home/work/django/sites/site1'] + sys.path"
    </Location>

    Alias /media "/home/work/django/media"

    <Directory "/home/work/django/media">
        Options Indexes FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>

    RewriteRule ^/media$ /media/ [R]
    <Location "/media/">
        SetHandler None
    </Location>
</VirtualHost>

site2 vhost config:
(Same as above, changing ServerName and PythonPath)

You don't need to make soft links in apps template folders if you configure properly settings.py:
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source ',
    'django.template.loaders.app_directories.load_template_source', # :-)
)

This layout works because we use the same server machine for django and static files. Probably in a more optimized environment you will need to copy application media folders to the static content server.

Nos vemos!
--
Obstáculos es lo que ves cuando apartas la vista del objetivo.

Kenneth Gonsalves

unread,
Jul 30, 2006, 9:13:02 PM7/30/06
to django...@googlegroups.com

On 31-Jul-06, at 1:45 AM, Guillermo Fernandez Castellanos wrote:

> Or more like:
> /site1/templates
> /media
> /urls.py
> /site2/templates
> /media
> /urls.p

this makes sense to me, with common stuff somewhere else central

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/


Guillermo Fernandez Castellanos

unread,
Jul 31, 2006, 12:27:37 PM7/31/06
to django...@googlegroups.com
It's much clear now. Everyone seems to agree the second solution is better.

I've been searching at the same time for the svn, and I've found that
no one does it the same way. But's also true an important number of
the projects are still in pre-magic state.

In the mean time I've also found 'Do's and dont's for application writers':
http://code.djangoproject.com/wiki/DosAndDontsForApplicationWriters
They say "To avoid clashes, use a name for the project which is unique
to you, the author, such as one based on a domain name that you own."

From an svn point of view, wold you then do something like this?
ibofobi/
apps/
mnemosyne/
branches/
tags/
trunk/
and force contributors to checkout to a directory ibofobi/apps/mnemosyne?
Or should this be part of the settings.py somehow as a variable?

Thanks a lot, I fid those organization questions are non-trivial for me.

G

Reply all
Reply to author
Forward
0 new messages