当前位置: 首页>>代码示例>>Python>>正文


Python static.static方法代码示例

本文整理汇总了Python中django.templatetags.static.static方法的典型用法代码示例。如果您正苦于以下问题:Python static.static方法的具体用法?Python static.static怎么用?Python static.static使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.templatetags.static的用法示例。


在下文中一共展示了static.static方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: last_beat_column

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def last_beat_column(self, object):
        last_beat = object.last_beat
        if is_aware(last_beat):
            # Only for USE_TZ=True
            last_beat = localtime(last_beat)

        last_beat_str = localize(last_beat)
        if object.is_expired:
            # Make clearly visible
            alert_icon = static('admin/img/icon-alert.svg')
            return format_html(
                '<div style="vertical-align: middle; display: inline-block;">'
                '  <img src="{}" style="vertical-align: middle;"> '
                '  <span style="color: #efb80b; vertical-align: middle;">{}</span>'
                '</div>',
                alert_icon, last_beat_str
            )
        else:
            return last_beat_str 
开发者ID:mvantellingen,项目名称:django-healthchecks,代码行数:21,代码来源:admin.py

示例2: rich_edit_static

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def rich_edit_static(context):

    files = [
        "<link href=\"%s\" rel=\"stylesheet\"/>" % static(
            "simplemde/simplemde.min.css"),
        "<link href=\"%s\" rel=\"stylesheet\"/>" % static(
            "font-awesome/css/font-awesome.min.css"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/marked.min.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/simplemde.min.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/inline-attachment.min.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/codemirror.inline-attachment.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/markdown.js")
    ]
    return mark_safe("\n".join(files)) 
开发者ID:certsocietegenerale,项目名称:FIR,代码行数:21,代码来源:markdown.py

示例3: mark_read

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def mark_read(request, message_id, dispatch_id, hashed, redirect_to=None):
    """Handles mark message as read request.

    :param Request request:
    :param int message_id:
    :param int dispatch_id:
    :param str hashed:
    :param str redirect_to:
    :return:
    """
    if redirect_to is None:
        redirect_to = get_static_url('img/sitemessage/blank.png')

    return _generic_view(
        'handle_mark_read_request', sig_mark_read_failed,
        request, message_id, dispatch_id, hashed, redirect_to=redirect_to
    ) 
开发者ID:idlesign,项目名称:django-sitemessage,代码行数:19,代码来源:views.py

示例4: _add_lazy_manager

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def _add_lazy_manager(self):
        if hasattr(self.response, "content"):
            doc = BeautifulSoup(self.response.content, "html.parser")

            if doc.body:
                doc.body["data-wtm-config"] = reverse("wtm:config")
                doc.body["data-wtm-lazy"] = reverse("wtm:lazy")

                if getattr(settings, "WTM_INJECT_STYLE", True):
                    link = doc.new_tag("link")
                    link["rel"] = "stylesheet"
                    link["type"] = "text/css"
                    link["href"] = static("wagtail_tag_manager/wtm.bundle.css")
                    doc.body.append(link)

                if getattr(settings, "WTM_INJECT_SCRIPT", True):
                    script = doc.new_tag("script")
                    script["type"] = "text/javascript"
                    script["src"] = static("wagtail_tag_manager/wtm.bundle.js")
                    doc.body.append(script)

            self.response.content = doc.decode() 
开发者ID:jberghoef,项目名称:wagtail-tag-manager,代码行数:24,代码来源:middleware.py

示例5: media

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def media(self):
        """
        Construct Media as a dynamic property.
        .. Note:: For more information visit
            https://docs.djangoproject.com/en/stable/topics/forms/media/#media-as-a-dynamic-property
        """
        lang = get_language()
        select2_js = (settings.SELECT2_JS,) if settings.SELECT2_JS else ()
        select2_css = (settings.SELECT2_CSS,) if settings.SELECT2_CSS else ()

        i18n_name = SELECT2_TRANSLATIONS.get(lang)
        if i18n_name not in settings.SELECT2_I18N_AVAILABLE_LANGUAGES:
            i18n_name = None

        i18n_file = (
            ('%s/%s.js' % (settings.SELECT2_I18N_PATH, i18n_name),)
            if i18n_name
            else ()
        )

        return forms.Media(
            js=select2_js + i18n_file + (static("js/django_select2.js"), ),
            css={'screen': select2_css}
        ) 
开发者ID:dissemin,项目名称:dissemin,代码行数:26,代码来源:widgets.py

示例6: versioned_static

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def versioned_static(path):
    """
    Wrapper for Django's static file finder to append a cache-busting query parameter
    that updates on each Wagtail version
    """
    # An absolute path is returned unchanged (either a full URL, or processed already)
    if path.startswith(('http://', 'https://', '/')):
        return path

    base_url = static(path)

    # if URL already contains a querystring, don't add our own, to avoid interfering
    # with existing mechanisms
    if VERSION_HASH is None or '?' in base_url:
        return base_url
    else:
        return base_url + '?v=' + VERSION_HASH 
开发者ID:wagtail,项目名称:wagtail,代码行数:19,代码来源:staticfiles.py

示例7: get_context_data

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def get_context_data(self, **kwargs):
        context = super(DocView, self).get_context_data(**kwargs)
        context['login_js_url'] = static('widget/js/login.min.js')
        context['Message_ID'] = make_msgid()
        context['SORTED_DISCIPLINES'] = SORTED_DISCIPLINES
        context['DEGREES'] = DEGREES
        context['HOSTELS'] = HOSTELS
        context['SEXES'] = SEXES
        context['USER_TYPES'] = UserProfile.objects.values_list('type').distinct()

        # Mark all tabs as inactive
        for tab_ in self.tabs:
            tab_.is_active = False

        tab = context.get('tab', '')
        for tab_ in self.tabs:
            if tab == tab_.tab_name:
                tab = tab_
                break
        else:
            tab = self.tabs[0]
        tab.is_active = True
        context['tabs'] = self.tabs
        context['active_tab'] = tab
        return context 
开发者ID:DheerendraRathor,项目名称:ldap-oauth2,代码行数:27,代码来源:views.py

示例8: get_plugin_placeholder_markup

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def get_plugin_placeholder_markup(group_type='all', group_id=None):
    result = []
    hidden = get_hidden_plugins(group_type, group_id)
    group_oses = get_member_oses(group_type, group_id)
    display_plugins = [p for p in Plugin.objects.exclude(name__in=hidden).order_by('order')]
    for enabled_plugin in display_plugins:
        name = enabled_plugin.name
        yapsy_plugin = PluginManager.get_plugin_by_name(name)
        if not yapsy_plugin:
            continue
        # Skip this plugin if the group's members OS families aren't supported
        # ...but only if this group has any members (group_oses is not empty
        plugin_os_families = set(yapsy_plugin.get_supported_os_families())
        if group_oses and not plugin_os_families.intersection(group_oses):
            continue
        width = yapsy_plugin.get_widget_width(group_type=group_type, group_id=group_id)
        html = ('<div id="plugin-{}" class="col-md-{}">\n'
                '    <img class="center-block blue-spinner" src="{}"/>\n'
                '</div>\n'.format(name, width, static('img/blue-spinner.gif')))
        result.append({'name': name, 'width': width, 'html': html})

    return order_plugin_output(result) 
开发者ID:salopensource,项目名称:sal,代码行数:24,代码来源:utils.py

示例9: render

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def render(self, name, value, attrs=None,):

        substitutions = {
            'clear_checkbox_label': self.clear_checkbox_label,
            'initial' : '<img class="img-responsive img-thumbnail" width="%s" src="%s">' % (
                force_text('100%'),
                force_text(get_thumbnailer(value)['medium'].url if value and hasattr(value, 'url') else static('images/placeholder.svg'))
            )
        }
        template = '%(initial)s%(input)s'

        substitutions['input'] = super(ClearableFileInput, self).render(name, value, attrs)

        if not self.is_required:
            template = '%(initial)s%(clear_template)s%(input)s'
            checkbox_name = self.clear_checkbox_name(name)
            checkbox_id = self.clear_checkbox_id(checkbox_name)
            substitutions['clear_checkbox_name'] = conditional_escape(checkbox_name)
            substitutions['clear_checkbox_id'] = conditional_escape(checkbox_id)
            substitutions['clear'] = CheckboxInput().render(checkbox_name, False, attrs={'id': checkbox_id})
            substitutions['clear_template'] = self.clear_checkbox_name(checkbox_name)

        return mark_safe(template % substitutions) 
开发者ID:freedomvote,项目名称:freedomvote,代码行数:25,代码来源:widgets.py

示例10: manifest

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def manifest(request):
    data = {
        "name": settings.SITE_NAME,
        "short_name": settings.SITE_NAME,
        "icons": [
            {
                "src": static("imgs/megmelon-icon-white.png"),
                "sizes": "128x128",
                "type": "image/png"
            }
        ],
        "theme_color": "#ffffff",
        "background_color": "#ffffff",
        "display": "browser",
        "start_url": reverse("user-home"),
    }

    return JsonResponse(data) 
开发者ID:Inboxen,项目名称:Inboxen,代码行数:20,代码来源:manifest.py

示例11: test_absolute_url

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def test_absolute_url(self):
        m = Media(
            css={'all': ('path/to/css1', '/path/to/css2')},
            js=(
                '/path/to/js1',
                'http://media.other.com/path/to/js2',
                'https://secure.other.com/path/to/js3',
                static('relative/path/to/js4'),
            ),
        )
        self.assertEqual(
            str(m),
            """<link href="https://example.com/assets/path/to/css1" type="text/css" media="all" rel="stylesheet">
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
<script type="text/javascript" src="https://example.com/assets/relative/path/to/js4"></script>"""
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:21,代码来源:test_forms.py

示例12: bundle

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def bundle(bundle_name, extension=None, config='DEFAULT', attrs=''):
    if settings.WEBPACK_LOADER_ENABLED:
        return render_bundle(
            bundle_name, extension=extension, config=config, attrs=attrs)
    else:
        tags = []
        extensions = (extension, ) if extension is not None else ('js', 'css')

        prefix = settings.WEBPACK_LOADER[config]['BUNDLE_DIR_NAME']
        prefix = prefix.rstrip("/")

        for ext in extensions:
            url = static(f'{prefix}/{ext}/{bundle_name}.{ext}')

            t = TEMPLATES.get(ext)

            if t is not None:
                tags.append(t.format(url, attrs))

        return mark_safe("\n".join(tags)) 
开发者ID:TheSpaghettiDetective,项目名称:TheSpaghettiDetective,代码行数:22,代码来源:vue.py

示例13: build_js_init_arguments

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def build_js_init_arguments(self):
        args = super(DigiHelTinyMCERichTextArea, self).build_js_init_arguments()
        args.update(
            plugins=self.plugins,
        )
        args.pop('menubar', None)  # Always enable the menubar
        args['content_css'].append(static('css/tinymce-content.css'))
        args['skin'] = 'wagtail'
        args['height'] = 600
        args['style_formats'] = [
            {'title': 'Additional info','block': 'section','classes': 'more-info', 'wrapper': 'true'},
            {'title': 'Document link','inline': 'span','classes': 'document-link'},
        ]
        args['style_formats_merge'] = True
        args['extended_valid_elements'] = 'div[class]'
        return args 
开发者ID:City-of-Helsinki,项目名称:digihel,代码行数:18,代码来源:tinymce.py

示例14: xstatic

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def xstatic(*tags):
    from .vendors import vendors
    node = vendors

    fs = []
    lang = get_language()

    cls_str = str if six.PY3 else basestring
    for tag in tags:
        try:
            for p in tag.split('.'):
                node = node[p]
        except Exception as e:
            if tag.startswith('xadmin'):
                file_type = tag.split('.')[-1]
                if file_type in ('css', 'js'):
                    node = "xadmin/%s/%s" % (file_type, tag)
                else:
                    raise e
            else:
                raise e

        if isinstance(node, cls_str):
            files = node
        else:
            mode = 'dev'
            if not settings.DEBUG:
                mode = getattr(settings, 'STATIC_USE_CDN',
                               False) and 'cdn' or 'production'

            if mode == 'cdn' and mode not in node:
                mode = 'production'
            if mode == 'production' and mode not in node:
                mode = 'dev'
            files = node[mode]

        files = type(files) in (list, tuple) and files or [files, ]
        fs.extend([f % {'lang': lang.replace('_', '-')} for f in files])

    return [f.startswith('http://') and f or static(f) for f in fs] 
开发者ID:stormsha,项目名称:StormOnline,代码行数:42,代码来源:util.py

示例15: static

# 需要导入模块: from django.templatetags import static [as 别名]
# 或者: from django.templatetags.static import static [as 别名]
def static(path):
    global _static
    if _static is None:
        if apps.is_installed('django.contrib.staticfiles'):
            from django.contrib.staticfiles.templatetags.staticfiles import static as _static
        else:
            from django.templatetags.static import static as _static
    return _static(path) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:10,代码来源:admin_static.py


注:本文中的django.templatetags.static.static方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。