views:

147

answers:

1

I have a Django project where the company will have a main site like www.ourcompany.org and a bunch of sub-domains like project.ourcompany.org. Content appearing in the sub-domains like case studies should also appear in the main site. I've decided to use multiple instances of Django BUT one database for each sub-domain so that I can have some flexibility and take advantage of the Sites framework. What I'm not sure of is how to access the models across the multiple instances. If I have a model:

class CaseStudy(models.Model):
    title=models.CharField(max_length=100)
    site=models.ManyToMany(Site)

Do I need to create this model in every instance so that I can have access to the object?

+1  A: 

I'll just assume you have good reasons for having separate django instances rather than doing smart URL parsing in a single django project, since that seems easier to me. But I can see reasons to do it the hard way too.

Please don't copy the model code into each of your projects -- that way leads to madness. Instead, put the models that you want to share into a common directory and make sure it's included your PYTHONPATH environment variable so each instance can find it.

Leopd
I haven't tried looked at smart URL parsing,I had a look at http://effbot.org/zone/django-multihost.htm but which seems to be one option to try. I just figured that multiple instances would be better based on the Sites framework. In my project each sub-domain will have web editor who would manage that content.
jwesonga