You could do this on PythonAnywhere by having two web apps on the "Web" tab.
Let's say that your production site is viewed by your users on www.mydomain.com
. At any one time, you'd have two web apps on the "Web" tab:
www.mydomain.com
alternate.mydomain.com
They'd have different codebases, but be connected to the same database on the backend. (Keeping everything consistent so that different versions of the code could run with different versions of the database, but this is a general problem with this kind of deployment, not PythonAnywhere.)
When you had some changes that you wanted to try, you'd push them to the source code directory associated with alternate.mydomain.com
. You could access that site, and check that it was OK. If it was, you'd then:
- Rename
www.mydomain.com
to somethingelse.mydomain.com
- Rename
alternate.mydomain.com
to www.mydomain.com
- Rename
somethingelse.mydomain.com
to alternate.mydomain.com
You would see some warnings on the "Web" tab about CNAMEs, but they should be ignorable.