本文整理匯總了Python中django.conf.settings.DOMAIN屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.DOMAIN屬性的具體用法?Python settings.DOMAIN怎麽用?Python settings.DOMAIN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.conf.settings
的用法示例。
在下文中一共展示了settings.DOMAIN屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def handle(self, *args, **options):
super(Command, self).handle(*args, **options)
self.message(str(options), 3)
self.verbosity = options['verbosity']
dryRun = options['dry_run']
template = options['template']
volunteersFile = options['volunteers_list']
sender = options['sender']
event = options['event']
volunteers = volunteer.parse_volunteer_info_file(volunteersFile)
volunteer.send_volunteer_mail(
settings.DOMAIN,
event,
volunteers,
template,
sender,
verbosity=self.verbosity,
dry_run=dryRun,
)
示例2: mutate
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def mutate(self, info, email):
try:
user = User.objects.get(email=email)
except User.DoesNotExist:
errors = ['emailDoesNotExists']
return ResetPassword(success=False, errors=errors)
params = {
'user': user,
'DOMAIN': settings.DOMAIN,
}
send_mail(
subject='Password reset',
message=render_to_string('mail/password_reset.txt', params),
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[email],
)
return ResetPassword(success=True)
示例3: make_absolute_url
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def make_absolute_url(relative_url, protocol=None):
"""
Takes a relative url and makes it absolute by prepending the Canvas absolute domain.
This refers not to relative as in "foo" resolving to "/bar/foo" when you're already on "/bar", but to an
absolute path sans the host portion of the URL.
`protocol` should be the name without the "://", e.g. "http" or "https"
"""
# Is it already absolute?
if relative_url.split('//')[-1].startswith(settings.DOMAIN) and relative_url.startswith(protocol or '//'):
return relative_url
if protocol:
protocol = protocol + '://'
else:
protocol = '//'
base = protocol + settings.DOMAIN
return urljoin(base, relative_url)
示例4: test_full_stack
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def test_full_stack(self):
path = Config['test_bgwork_path']
if os.path.isfile(path):
os.remove(path)
# Post a fact.
resp = urllib2.urlopen('http://{}/api/testing/test_bgwork'.format(settings.DOMAIN))
# Look for the fact.
TIMEOUT = 10 # s
t = time.time()
while True:
time.sleep(.3)
if os.path.isfile(Config['test_bgwork_path']):
break
if time.time() - t > TIMEOUT:
raise Exception("test_bgwork flag file wasn't written.")
示例5: make_winner_url
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def make_winner_url(self, domain=settings.DOMAIN):
return (
domain
+ reverse('tracker:prize_winner', args=[self.pk])
+ '?auth_code={0}'.format(self.auth_code)
)
示例6: automail_inactive_prize_handlers
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def automail_inactive_prize_handlers(
event,
inactiveUsers,
mailTemplate,
sender=None,
replyTo=None,
domain=settings.DOMAIN,
verbosity=0,
dry_run=False,
):
sender, replyTo = event_sender_replyto_defaults(event, sender, replyTo)
for inactiveUser in inactiveUsers:
eventPrizes = list(
Prize.objects.filter(handler=inactiveUser, event=event, state='ACCEPTED')
)
formatContext = {
'event': event,
'handler': inactiveUser,
'register_url': domain + reverse('tracker:register'),
'prize_set': eventPrizes,
'prize_count': len(eventPrizes),
'reply_address': replyTo,
}
if not dry_run:
post_office.mail.send(
recipients=[inactiveUser.email],
sender=sender,
template=mailTemplate,
context=formatContext,
headers={'Reply-to': replyTo},
)
message = 'Mailed prize handler {0} (#{1}) for account activation'.format(
inactiveUser, inactiveUser.id
)
if verbosity > 0:
print(message)
if not dry_run:
viewutil.tracker_log('prize', message, event)
示例7: expand_url_path
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def expand_url_path(path, domain=None):
domain = domain or settings.DOMAIN
url = urljoin('//{}'.format(domain), path)
return url[2:]
示例8: constants
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def constants(request):
'''
injects certain constants form settings module
into template context
'''
return {'DEBUG': settings.DEBUG,
'DOMAIN': settings.DOMAIN,
'API_URL': settings.API_URL,
'STATIC_URL': settings.STATIC_URL,
'VERSION': settings.VERSION}
示例9: create
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def create(self, validated_data):
validated_data["is_active"] = False
instance = super(UserRegSerializer, self).create(validated_data=validated_data)
instance.email = "{}{}".format(instance.username, settings.DOMAIN)
instance.set_password(validated_data["password"])
instance.id_rsa_key, instance.id_rsa_pub = self.get_sshkey(instance.email)
instance.save()
return instance
示例10: _upload_image_to_imgur
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def _upload_image_to_imgur(image_buffer, client_id):
tmp_path = os.path.join(settings.MEDIA_ROOT, f'{uuid4()}.jpg')
with open(tmp_path, 'wb') as fw:
fw.write(image_buffer)
headers = {'Authorization': f'Client-ID {client_id}'}
data = {'image': image_buffer}
resp = requests.post(
'https://api.imgur.com/3/upload',
data=data,
headers=headers,
)
try:
resp_data = resp.json()
if 'errors' in resp_data:
credit_resp = requests.get(
'https://api.imgur.com/3/credits',
headers=headers,
)
LOGGER.error(f'Error upload to imgur. The credits remaining: {credit_resp.json()}')
path = urljoin(urljoin(settings.DOMAIN, settings.MEDIA_URL), os.path.basename(tmp_path))
else:
path = resp_data['data']['link']
except Exception as e:
LOGGER.error(f'Error parsing imgur response data: {resp_data}')
path = urljoin(urljoin(settings.DOMAIN, settings.MEDIA_URL), os.path.basename(tmp_path))
return path
示例11: password_reset
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def password_reset(self, request, format=None):
if User.objects.filter(email=request.data['email']).exists():
user = User.objects.get(email=request.data['email'])
params = {'user': user, 'DOMAIN': settings.DOMAIN}
send_mail(
subject='Password reset',
message=render_to_string('mail/password_reset.txt', params),
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[request.data['email']],
)
return Response(status=status.HTTP_200_OK)
else:
return Response(status=status.HTTP_404_NOT_FOUND)
示例12: item_description
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def item_description(self, item):
if item.poster:
return "<div><img src=\"{}\" style=\"width: 200px;\"/><p>{}</p></div>".format(urllib.parse.urljoin(settings.DOMAIN, item.poster.url), item.plot)
return item.plot
示例13: item_link
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def item_link(self, item):
return urllib.parse.urljoin(settings.DOMAIN, reverse('watch', kwargs={'mid': item.id}))
示例14: full_url
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def full_url(url_fragment):
"""
Given a fragment, return that fragment joined to the full Open Humans URL.
"""
if url_fragment and not url_fragment.startswith("/"):
return url_fragment
return urllib.parse.urljoin(
settings.DEFAULT_HTTP_PROTOCOL + "://" + settings.DOMAIN, str(url_fragment)
)
示例15: inline_the_styles
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DOMAIN [as 別名]
def inline_the_styles(self):
self.body_html = premailer.transform(self.raw_body_html, base_url="http://" + settings.DOMAIN + "/")