當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。