我有电子邮件模板: 激活:{{site}} / accounts / activate / {{activation_key}} /
我想将{{site}}设置为localhost。如果没有django-admin面板,我怎么能这样做呢。 我想为此使用CONSTANT。
答案 0 :(得分:0)
来自django docs:https://docs.djangoproject.com/en/dev/ref/contrib/sites/
from django.contrib.sites.shortcuts import get_current_site
def my_view(request):
current_site = get_current_site(request)
if current_site.domain == 'foo.com':
# Do something
pass
else:
# Do something else.
pass
网站信息可以传递到您的模板