Forums

Linking multiple domains towards one app

I have two domains that I would link to one app in pythonanywhere. I have tried to use the CNAME in both of them, but only one is forwarded to my app, the other gets the "Coming Soon! This is going to be another great website...". How could I get this to work?

Each domain that's hosted by PythonAnywhere needs to have a separate web app associated with it on the "Web" tab -- so if you add one there, then it should work.

Of course, you want them to run the same code -- to do that, copy the contents of the WSGI file from one on top of the other one's, and then make sure that the other settings on the "Web" tab (static files etc) all match.

I have a similar problem... I would like both example.com and www.example.com to point to the same web app. I got the first to work, but the www subdomain get's me a "coming soon...".

Is there really no other way than to use two web apps? Maybe I'm missing some DNS trickery...

What you'd normally do on PythonAnywhere is set up www.example.com on our site, then set up what's called a "domain redirect" or "domain forwarding" with your domain name registrar so that requests to example.com get transparently redirected to www.example.com.

Check out this help page for more information, including some details on the redirection.

Django has the Sites framework that lets you link multiple domains to the same Django application. We need to use this Sites framework.

Re-direct is not an option as the app has to actually run using the domain as with the Django Sites framework the app will work, behave and even look different depending on the domain (or in Django terms Site).

How to do this on PythonAnywhere?

Unfortunately on PythonAnywhere, each separate domain or subdomain needs to be set up on the "Web" page as a separate website, even if they share the code. So having a large number of subdomains would require each one to be configured there, which would incur further costs, and would probably not work out being cost-effective.

Thank you for the quick reply. Sorry for posting it twice but I found a more recent forum post after I already posted my issue here. Yes indeed, having to create a new web app for each new domain does not seem like the correct solution.

Few questions:

1) Can each web-app use the same database?

2) Can each web-app use the same static and media settings, working directory and WSGI configuration file?

3) Can each web-app refer to the same source code folder?

4) If the above questions are answered with yes can you think of any potential problems running multiple web apps with the same resources?

5) Sites framework is a standard core part of Django. Will PythonAnywhere support Django applications including the Sites framework by allowing multiple domains for each web-app in the near future?

1) Can each web-app use the same database?

Yes

2) Can each web-app use the same static and media settings, working directory and WSGI configuration file?

Yes, apart from the WSGI file -- you have to deploy each web app via the Web page, which will result in creation of a separate wsgi file for each of them. Contents of those files can be the same, though.

3) Can each web-app refer to the same source code folder?

Yes

4) If the above questions are answered with yes can you think of any potential problems running multiple web apps with the same resources?

The major issue that comes to my mind is the database state -- depending on what your apps are doing, you should probaby consider if there would be no clash in data (e.g. users trying to create an account with the same handle on different sites).

5) Sites framework is a standard core part of Django. Will PythonAnywhere support Django applications including the Sites framework by allowing multiple domains for each web-app in the near future?

No, we're not planning to change the way we treat domains on PA right now.

Partially good news

"you should probably consider if there would be no clash in data (e.g. users trying to create an account with the same handle on different sites)."

Isn't this handled primarily by the database and wouldn't you have the same potential issue with a single instance Django app?

No, we're not planning to change the way we treat domains on PA right now."

Does this then essentially mean that you are not fully supporting Django web-applications? Since for Django Site framework (which is part of core Django) to work you should be able to link multiple domains to the same web-application.