我在哪里设置django设置中的网站网址?

时间:2022-01-30 22:56:58

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.

好吧,我想我一定错过了什么。在settings.py中,我没有看到网站的绝对网址设置。我看到有MEDIA_URL。

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

django-registration引用{{site}},它默认为example.com但我在任何设置中都没有看到它。

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

如果我想让dev.mysite.com和mysite.com独立工作,我需要在settings.py中添加什么?

2 个解决方案

#1


7  

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

该站点使用站点框架。 example.com域在数据库中定义,可以使用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个站点,您必须更改设置中的SITE_ID,并在Django Admin中添加额外站点。

#2


1  

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).

如果您只想从自己的代码中使用它 - 只需将域放在settings-production.py和settings-dev.py(或您选择调用它们的任何内容)中的变量中。

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

django本身不会关注你指定的域名 - 但它不需要。

#1


7  

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

该站点使用站点框架。 example.com域在数据库中定义,可以使用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个站点,您必须更改设置中的SITE_ID,并在Django Admin中添加额外站点。

#2


1  

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).

如果您只想从自己的代码中使用它 - 只需将域放在settings-production.py和settings-dev.py(或您选择调用它们的任何内容)中的变量中。

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

django本身不会关注你指定的域名 - 但它不需要。