WebFaction
Community site: login faq

Hello,

I am putting together a health resource database. I need to have a Spanish clone site, so that certain things in the static html will be translated from English and only certain fields in the database will be extracted, etc. I would like to know if it is possible to tie subdomains directly to different Django projects that reside within the same Django application (eg: webapp1).

sp.mywebsite.com ---directs to--> webapp1/project1 (spanish version)

mywebsite.com --directs to--> webapp1/project2 (regular version)

Is this feasible to do without creating an entirely new application for the spanish clone site?

Thanks!

Best Regards,

Matt

asked 18 Dec '10, 18:18

mhjohnson
112
accept rate: 0%


Don't you need to do this in your urls.py based on the domain of the request?

Is this useful? http://stackoverflow.com/questions/676457/how-do-i-set-urlpatterns-based-on-domain-name-or-tld-in-django

permanent link

answered 18 Dec '10, 18:35

Acorn
382815
accept rate: 0%

It is possible, however it is not supported as it can cause a bottleneck for the apache server processing the python data into HTML and thus timeout. There is a post on our old forum with an explanation on how to do this,

http://forum.webfaction.com/viewtopic.php?id=3646

permanent link

answered 18 Dec '10, 18:38

johns ♦♦
5.3k212
accept rate: 23%

You should be able to get,

sp.mywebsite.com ---directs to--> project1 (spanish version)
mywebsite.com --directs to--> project2 (regular version)

By using the control panel to point the sub-domains to 2 separate applications..

(18 Dec '10, 18:40) johns ♦♦

Acorn and Johns, you both have contributed to my question very well.

@Johns: Yes, it appears that I will need a different server instance for each project. However, does that mean I need to start a totally different Django application, or can I create separate wsgi applications within the same application folder?

This an example from stackoverflow:

# site_fr.wsgi

import os, sys, django.core.handlers.wsgi

os.environ['DJANGO_SETTINGS_MODULE'] = 'app.settings_fr'

application = django.core.handlers.wsgi.WSGIHandler()

... and so on along with matching apache virtual host for each site:

<VirtualHost *:80>

    ServerName mybooks.fr

    WSGIScriptAlias / /path/to/site_fr.wsgi

...

</VirtualHost>'42

@Acorn: Thank-you. Configuring the urls that way totally slipped my mind, and it will certainly help keep the DRY principle. It would be a pain to sync the two different projects together constantly. So, should I keep both translations within the same project folder, and just have different project subfolders and templates?

permanent link

answered 18 Dec '10, 19:12

mhjohnson
112
accept rate: 0%

You can do both, however it is safer and easier to simply user 2 separate Django applications.

(18 Dec '10, 19:21) johns ♦♦

I'm guessing you've already considered this, but in case not, there is also apparently a fairly robust translation engine in Django, which allows you to simply use tags like {% trans "Whatever" %}. But I'm guessing it's not fit for a lot of text or professional site-standards, given the occasional silly translations from using google's site-translation, which is probably similar engine.

permanent link

answered 27 Feb '11, 12:12

Nicolai_Mork
111
accept rate: 0%

@Nicolai_Mork Django translation engine doesn't work like Google Translate ... it doesn't do automatic translations, you have to manually provide translations for all the phrases you use like {% trans "Whatever" %} ... see http://docs.djangoproject.com/en/1.2/topics/i18n/localization/

Personally, unless the two sites have radically different functionality I'd be inclined to build as a single Django project, using the Django i18n machinery and switching other functionality in the views based on Django sites framework, as in @Acorn's answer. But I don't know how that fits with WebFaction setup.

permanent link

answered 04 Mar '11, 07:20

anentropic
81710
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×904
×17
×2
×2
×1

question asked: 18 Dec '10, 18:18

question was seen: 6,747 times

last updated: 04 Mar '11, 07:20

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM