What is the recommended way of laying out the filesystem when doing
multiple sites? Let's say I have two sites, "foo" and "bar", with URLs
foo.com and bar.com.
Would you put all the files for both sites into one Django project, or
would you give each its own project?
When I say "both sites into one Django project", I mean something like this:
myproject/
foo/
settings.py
urls.py
app1/
app2/
templates/
bar/
settings.py
urls.py
app3/
app4/
templates/
Then the vhost configurations for each site can point to the
individual settings files, the sites can potentially share
applications, and they can easily share models.
I suppose the same could be done by having each site in its own
project (after all, these are just Python packages and modules), but
it seems like I wouldn't want shared models crossing project domains
like that. That's just a purely conceptual idea though.
And that's the other thing, models. Say I have a model "Baz", that is
used by app1 in "foo", and by app3 in "bar". Where would I define it?
I would guess I can arbitrarily choose to define it in either
foo.models or bar.models. Or would it make any sense to define it
somewhere else entirely, so it's not directly coupled to only one app?
Thanks,
Jay P.
Jay P.
Do you use the Sites framework for any of this though? That's the
thing I'm having a conceptual problem with.
More specifically, I'm not quite sure how to configure a project to
use the Sites framework. Namely, what to do with settings.py files? I
know to give each site unique SITE_ID values.
But then it *seems* that all the settings.py files have to have the
same SECRET_KEY, or I get a "User tampered with session cookie" error.
Also, how are we supposed to associate sites that we add through the
admin to a SITE_ID? The sites in the Admin don't actually show the
SITE_ID they're associated with.
I just can't seem to find any guidelines for configuring settings.py
properly to use the Sites framework.
Jay P.
On 8/2/06, Ian Holsman <kry...@gmail.com> wrote:and obviously not all the sites are identical (they have different hostnamesand possibly different things enabled for that site) .. they go in thesite_NN directory.I usually have a group of 'shared' URL roots..url_app_X.pyand of course i have a set of N settings files which are hostname specific.setting_hostname.pyso far this structure has worked for the 6-7 sites I run, and 3-4 projects Iam using.Do you use the Sites framework for any of this though? That's thething I'm having a conceptual problem with.
More specifically, I'm not quite sure how to configure a project touse the Sites framework. Namely, what to do with settings.py files? Iknow to give each site unique SITE_ID values.But then it *seems* that all the settings.py files have to have thesame SECRET_KEY, or I get a "User tampered with session cookie" error.
Also, how are we supposed to associate sites that we add through theadmin to a SITE_ID? The sites in the Admin don't actually show theSITE_ID they're associated with.
I just can't seem to find any guidelines for configuring settings.pyproperly to use the Sites framework.
Jay P.
Perfect. These steps (and the SESSION_COOKIE_NAME) are exactly what
I've been looking for. Thanks Ian.
Jay P.