I have a server running a django application. This version is stable.
For testing purposes I want to host a testing version of the same application on the server in parallel. Both applications have the similar views.
Normally you could do this with subdomains, so the stable version runs at myserver.de
and the testing version at test.myserver.de
. This is not possible for me, I have only one available domain (myserver.de
).
So I can only use paths. Let's say I host the stable version at myserver.de/[apps urls]
and the test version at myserver.de/test/[apps urls]
.
To achieve this, i could edit all urls in the testing version. But that would defeat the purpose of testing, because to then make a testing version stable, i would have to re-edit all urls.
So I would like to simply edit settings.py
and put ALLOWED_HOSTS = ["mysite.de/test"]
for the testing version. I tested this locally with ALLOWED_HOSTS = ["127.0.0.1:8000/test", "127.0.0.1/test"]
, but that unsurprisingly didn't work (I read the docs ^^)
Is there a way to run two applications on a django server where the urls of one app always start with /test/<rest>
without editing all urls?
Could I do this with apache2 instead? (My guess was no, because django builds all links in the templates, so it must know about being "inside" /test
.
question from:
https://stackoverflow.com/questions/65831067/can-a-django-url-contain-a-fixed-path-at-the-beginning 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…