1👍
The Sites framework comes to mind.
Apart from that we have Django running for multiple sites by symlinking Django to various docroots. Works like a charm, too.
1👍
I can see two quite distinct ways to do this:
- Use one database and the sites framework. Every post/picture/whatever model is connected to a Site and you always filter on Site. This requires a separate settings file for every database.
- Use one database for each and every site. This allows different users for every site, but requires duplication of everything that is stored in the database. It also requires a separate settings file pointing to the correct database.
Either way, you do not duplicate any code, only data.
—
If you need to do site-specific, or post-specific changes to ie. a template, you should read up on how Django loads templates. It allows you to specify a list, ie [“story_%d.html”, “story_site_%d.html”, “story.html”] and django will look for the templates in that order.
- [Answered ]-Why does django date filter gives me entries from the next day as welll
- [Answered ]-BooleanField custom validator not working
- [Answered ]-Django: name 'csrf_token' is not defined
- [Answered ]-Empty Chatterbot Conversation table in Django Admin
- [Answered ]-Filtering on Django Queryset
0👍
I just ran into this and ended up using a custom middleware class that:
- Fetch the HTTP_HOST
- Clean the HTTP_HOST (remove www, ports, etc.)
- Look up domain in a Website table that’s tied to each account.
- Set the account instance on the HTTPRequest object.
The throughout my view code I do lookups based on the account stored in the HTTPRequest objects.
Hope that helps someone in the future.
- [Answered ]-Login with facebook: django-allauth
- [Answered ]-Django – how to get back an empty choice in choice field?
- [Answered ]-Save() on a model instance not update the changed field on related model side
- [Answered ]-Django: forms.ModelChoiceField based on pk of calling view
Source:stackexchange.com