Python django.conf.settings 模块,HOST 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用django.conf.settings.HOST

项目:openbare    作者:openbare    | 项目源码 | 文件源码
def deprecated_settings(app_configs, **kwargs):
    issues = []
    if ('payment_statement' in settings.HOST):
        issues.append(
            Warning(
                "The setting HOST['payment_statement'] is no longer rendered.",
                hint="Create a FrontpageMessage through the admin interface instead.",
                obj='settings.HOST',
                id='openbare.W001'
            )
        )
    if ('use_statement' in settings.HOST):
        issues.append(
            Warning(
                "The setting HOST['use_statement'] is no longer rendered.",
                hint="Create a FrontpageMessage through the admin interface instead.",
                obj='settings.HOST',
                id='openbare.W002'
            )
        )
    return issues
项目:openbare    作者:openbare    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        """Return context dictionary for view."""
        context = super(IndexView, self).get_context_data(**kwargs)

        context['resources'] = get_lendable_resources(self.request.user)
        context['user_items'] = get_items_checked_out_by(self.request.user)
        context['checkout'] = False
        context['host'] = settings.HOST
        context['frontpage_messages'] = FrontpageMessage.objects.all()

        return context
项目:django-sspanel    作者:Ehco1996    | 项目源码 | 文件源码
def nodeinfo(request):
    '''??????????'''

    nodelists = []
    ss_user = request.user.ss_user
    user = request.user
    # ???????
    nodes = Node.objects.filter(level__lte=user.level, show='??').values()
    # ??????????????
    for node in nodes:
        # ??SSR?SS???
        obj = Node.objects.get(node_id=node['node_id'])
        node['ssrlink'] = obj.get_ssr_link(ss_user)
        node['sslink'] = obj.get_ss_link(ss_user)
        # ??????
        try:
            log = NodeOnlineLog.objects.filter(
                node_id=node['node_id']).order_by('-id')[0]
            node['online'] = log.get_oneline_status()
            node['count'] = log.get_online_user()
        except:
            node['online'] = False
            node['count'] = 0
        nodelists.append(node)
    # ????
    token = base64.b64encode(
        bytes(user.username, 'utf-8')).decode('ascii') + '&&' + base64.b64encode(bytes(user.password, 'utf-8')).decode('ascii')
    sub_link = settings.HOST + 'server/subscribe/' + token
    context = {
        'nodelists': nodelists,
        'ss_user': ss_user,
        'user': user,
        'sub_link': sub_link,
    }
    return render(request, 'sspanel/nodeinfo.html', context=context)
项目:QProb    作者:quant-trade    | 项目源码 | 文件源码
def api_main(request):
    api_host = "api.{}".format(settings.HOST)
    return render(request, '{}/api.html'.format(settings.TEMPLATE_NAME), {'api_domain': api_host })
项目:QProb    作者:quant-trade    | 项目源码 | 文件源码
def extra_context(request):
    cats = Category.objects.all()

    c = []
    for cat in cats:
        cats_ = {}
        cats_['cnt'] = Post.objects.filter(category=cat.title).count()
        cats_['title'] = cat.title
        cats_['slug'] = cat.slug
        if cats_['cnt'] > 0:
            c.append(cats_)

    archive = []
    years = Post.objects.dates('date', 'year')
    for year in years:
        archive.append({'year': year.year, 'cnt': Post.objects.filter(date__year=year.year).count()})

    return {'base_url': settings.BASE_URL[:-1],
            'sitename': settings.SITE_NAME,
            'cats': c,
            'keyword': settings.KEYWORD,
            'shot_site_name': settings.SHORT_SITE_NAME,
            'research_module': settings.RESEARCH_MODULE,
            'definitions_module': settings.DEFINITIONS_MODULE,
            'twitter_handle': settings.TWITTER_HANDLE,
            'facebook_handle': settings.FACEBOOK_HANDLE,
            'linkedin_handle': settings.LINKEDIN_HANDLE,
            'gplus_handle': settings.GOOGLE_PLUS_HANDLE,
            'logo_handle': settings.LOGO_HANDLE,
            'feedburner_uri': settings.FEEDBURNER_URI,
            'copyright': settings.COPYRIGHT,
            'search_title': settings.SEARCH_TITLE,
            'site_theme': settings.SITE_THEME,
            'first_page_title': settings.FIRST_PAGE_TITLE,
            'advert': settings.AD_CODE,
            'host': settings.HOST,
            'folder': settings.SITE_FOLDER,
            'years': archive,
            'mobile_app_url': settings.MOBILE_APP_URL,
            'app_name': 'aggregator' }
项目:iguana    作者:iguana-project    | 项目源码 | 文件源码
def ready(self):
        import issue.signals
        from django.contrib.sites.models import Site

        def db_table_exists(table_name):
            return table_name in connection.introspection.table_names()

        if db_table_exists('django_site'):
            site = Site.objects.get_current()
            site.domain = settings.HOST
            site.name = settings.HOST
            site.save()
项目:task-router-django    作者:TwilioDevEd    | 项目源码 | 文件源码
def create_workspace():
    try:
        workspace = first(CLIENT.taskrouter.workspaces.list(friendly_name=WORKSPACE_NAME))
        CLIENT.taskrouter.workspaces(workspace.sid).delete()
    except:
        pass

    events_callback = HOST+'/events'

    return CLIENT.taskrouter.workspaces.create(
            friendly_name=WORKSPACE_NAME,
            event_callback_url=events_callback,
            template=None)
项目:task-router-django    作者:TwilioDevEd    | 项目源码 | 文件源码
def create_workflow(workspace, queues):
    defaultTarget = {
        'queue': queues['sms'].sid,
        'Priority': 5,
        'Timeout': 30
    }

    smsTarget = {
        'queue': queues['sms'].sid,
        'Priority': 5,
        'Timeout': 30
    }

    voiceTarget = {
        'queue': queues['voice'].sid,
        'Priority': 5,
        'Timeout': 30
    }

    default_filter = {
        'queue': queues['default'].sid,
        'Expression': '1==1',
        'Priority': 1,
        'Timeout': 30
    }

    voiceFilter = {
        'expression': 'selected_product=="ProgrammableVoice"',
        'targets': [voiceTarget, defaultTarget]
    }

    smsFilter = {
        'expression': 'selected_product=="ProgrammableSMS"',
        'targets': [smsTarget, defaultTarget]
    }

    config = {
        'task_routing': {
            'filters': [voiceFilter, smsFilter],
            'default_filter': default_filter
        }
    }

    callback_url = HOST + '/assignment'

    return CLIENT.taskrouter.workspaces(workspace.sid)\
                 .workflows.create(friendly_name='Sales',
                                   assignment_callback_url=callback_url,
                                   fallback_assignment_callback_url=callback_url,
                                   task_reservation_timeout=15,
                                   configuration=json.dumps(config))