Django multisites for local development, advice on structure and workflow -


I have 2 different sites:

  • Sites need to share users ( Users can share some models (i.e. blogs), but no content has been created through these models (only every piece of content created by blog model will be seen
  • Sites look quite different so the content will not be shared

I still have space I am developing, and I am unsure about defining both sites, so I can go to each of the browsers, and then write the URL to map to my separate template.

< P> I have examined the documentation of malicious documents but I find it difficult to understand how it relates to my needs.

Thank you in advance,

Resolve your problems Has to have potential - sharing code / model is not the biggest problem, if you should you package them in a reusable application b e able to use them in various projects.

  • Use: Both the sites will basically run with the same code, use the same database. The contents of the content will be one if it works well if your sites There is only one functionality, maybe only different designs, if you have to go deeper into the Python code to optimize a site, then this is probably not the best option.

  • You can get a solution with the database for users and share users using each other for each site. Its main disadvantage is that user data and other data live in different databases, which means that you can not do Johns or something like that on them. There is no need to filter (this will separate your data very clearly, some content is related to a site or not).

  • You write yourself so that each project can not authenticate users against your external database, but against some external service.

I think the site is going to be easiest with the framework, though if a site requires deep customization that can affect other sites (like That for other DB schema examples) it can be difficult and you should be careful that every change can affect other site also.

To configure this solution you need a separate settings file for each site (you have to set at least SITE_ID per site). In addition, you can specify additional settings like individual template folders, for each site individually. The template TEMPLATE_DIRS = (('site_a / templates /') for this site, such as *

  Settings __init__.py base.py site_a.py # site_a.py from base import to * SITE_ID = 1 # ,)  

You can run the development server after manage.py --settings settings.site_a . You can do this for example if you specify in the settings, then use a different urls.py on each site. In the production you need two instances that run, for each site There is a reverse proxy to send the request for the correct example of settings and examples.


Comments