Where do I set my site url in django settings?

半城伤御伤魂 提交于 2019-12-23 11:46:46

问题


Ok I think I must be missing something. In settings.py I don't see the setting for absolute url for the site. I see there is MEDIA_URL.

django-registration references {{ site }} which is defaulting to example.com but I'm not seeing that in any settings.

If I want the dev.mysite.com and mysite.com to work independently, what do I need to put in settings.py?


回答1:


The site uses the sites framework. The example.com domain is defined in the database and can be changed with the Django admin.

To use 2 sites simultaneously you will have to change the SITE_ID in the settings and add the extra site in the Django Admin.




回答2:


If you only want to use it from your own code -- just put the domain in a variable in settings-production.py and settings-dev.py (or whatever you choose to call them).

django itself won't do pay any attention to the domain you specify -- but it doesn't need to.



来源:https://stackoverflow.com/questions/3536123/where-do-i-set-my-site-url-in-django-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!