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


Python staticfiles.static方法代码示例

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


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

示例1: count_matching_users

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def count_matching_users(self, rules, match_any):
        """ Calculates how many users match the given static rules
        """
        count = 0

        static_rules = [rule for rule in rules if rule.static]

        if not static_rules:
            return count

        User = get_user_model()
        users = User.objects.filter(is_active=True, is_staff=False)

        for user in users.iterator():
            if match_any:
                if any(rule.test_user(None, user) for rule in static_rules):
                    count += 1
            elif all(rule.test_user(None, user) for rule in static_rules):
                count += 1

        return count 
开发者ID:wagtail,项目名称:wagtail-personalisation,代码行数:23,代码来源:forms.py

示例2: clean

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def clean(self):
        cleaned_data = super(SegmentAdminForm, self).clean()
        Segment = self._meta.model

        rules = [
            form.instance for formset in self.formsets.values()
            for form in formset
            if form not in formset.deleted_forms
        ]
        consistent = rules and Segment.all_static(rules)

        if cleaned_data.get('type') == Segment.TYPE_STATIC and not cleaned_data.get('count') and not consistent:
            self.add_error('count', _('Static segments with non-static compatible rules must include a count.'))

        if self.instance.id and self.instance.is_static:
            if self.has_changed():
                self.add_error_to_fields(self, excluded=['name', 'enabled'])

            for formset in self.formsets.values():
                if formset.has_changed():
                    for form in formset:
                        if form not in formset.deleted_forms:
                            self.add_error_to_fields(form)

        return cleaned_data 
开发者ID:wagtail,项目名称:wagtail-personalisation,代码行数:27,代码来源:forms.py

示例3: get

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def get(self, request):

        blog_id = "4368769871770527749"
        blogger_service = gdata.blogger.client.BloggerClient()
        feed = blogger_service.GetFeed('http://www.blogger.com/feeds/' + blog_id + '/posts/default')
        entries = [{'title': entry.title.text,
                    'contents': mark_safe(entry.content.text),
                    'time': self.format_datetime(entry.published.text),
                    'author': entry.author[0].name.text
                    #'author_link': entry.author[0].uri.text
                   } for entry in feed.entry]

        events = json.loads(urllib2.urlopen(static('json/events.json')).read())

        resources = json.loads(urllib2.urlopen(static('json/resources.json')).read())

        return render(request, 'blog.html', {'entries': entries, 'events': events, 'resources': resources}) 
开发者ID:langcog,项目名称:wordbank,代码行数:19,代码来源:views.py

示例4: insert_editor_js

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def insert_editor_js():
    js_files = [
        # We require this file here to make sure it is loaded before the other.
        'wagtailadmin/js/draftail.js',
        'colourpicker/js/colourpicker.js',
    ]
    js_includes = format_html_join(
        '\n',
        '<script src="{0}"></script>',
        ((static(filename), ) for filename in js_files)
    )
    js_includes += format_html(
        "<script>window.chooserUrls.colourChooser = '{0}';</script>",
        reverse('wagtailcolourpicker:chooser')
    )
    return js_includes 
开发者ID:AccentDesign,项目名称:wagtailcolourpicker,代码行数:18,代码来源:wagtail_hooks.py

示例5: render_column

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def render_column(self, row, column):
        # We want to render user as a custom column
        if column == 'link':
            platform_type = self.collection.harvest_type.split('_')[0]
            return mark_safe(u'<a target="_blank" href="{0}"> <img src="{1}" alt="Link to {2} account for {3}" height="35" width="35"/></a>'.format(
                row.social_url(), static('ui/img/{}_logo.png'.format(platform_type)), platform_type, row.token))
        elif column == 'messages':
            msg_seed = ""
            for msg in self.seed_infos.get(row.seed_id, []):
                msg_seed += u'<li><p>{}</p></li>'.format(msg)
            for msg in self.seed_warnings.get(row.seed_id, []):
                msg_seed += u'<li><p>{}</p></li>'.format(msg)
            for msg in self.seed_errors.get(row.seed_id, []):
                msg_seed += u'<li><p>{}</p></li>'.format(msg)
            return mark_safe(u'<ul>{}</ul>'.format(msg_seed)) if msg_seed else ""

        elif column == 'uid':
            return mark_safe(u'<a href="{}">{}</a>'.format(reverse('seed_detail', args=[row.pk]),
                                                           row.uid)) if row.uid else ""
        elif column == 'token':
            return mark_safe(u'<a href="{}">{}</a>'.format(reverse('seed_detail', args=[row.pk]),
                                                           ui_extras.json_list(row.token))) if row.token else "" 
开发者ID:gwu-libraries,项目名称:sfm-ui,代码行数:24,代码来源:views.py

示例6: fontawesome_stylesheet

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def fontawesome_stylesheet():
    href = getattr(settings, 'FONTAWESOME_CSS_URL', static('fontawesome/css/font-awesome.min.css'))
    link = format_html('<link href="{0}" rel="stylesheet" media="all">', href)
    return link 
开发者ID:redouane,项目名称:django-fontawesome,代码行数:6,代码来源:fontawesome.py

示例7: get_image_url

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def get_image_url(self):
        if self.image:
            return self.image.url

        return static('image/anonymous.png') 
开发者ID:pythonkr,项目名称:pyconkr-2015,代码行数:7,代码来源:models.py

示例8: favicon

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def favicon(request):
    return HttpResponseRedirect(static("img/favicon.ico")) 
开发者ID:mozilla,项目名称:normandy,代码行数:4,代码来源:views.py

示例9: get_js_path

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def get_js_path(file):
    """
    Get the correct path for the js file to include in the form.
    """
    path = ''.join(['js/', file])
    return static(path) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:8,代码来源:form_display.py

示例10: xstatic

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles 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

示例11: valid

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def valid(self, obj):
        if obj.validation_warning == True:
            return mark_safe('<img src="%s">' % static('admin/img/icon-alert.svg'))
        elif obj.validation_ok == True:
            return mark_safe('<img src="%s">' % static('admin/img/icon-yes.svg'))
        elif obj.validation_ok == False:
            return mark_safe('<img src="%s">' % static('admin/img/icon-no.svg'))
        return '' 
开发者ID:cyanfish,项目名称:heltour,代码行数:10,代码来源:admin.py

示例12: static

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles 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

示例13: global_admin_css

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def global_admin_css():
    """Add /static/css/wagtail.css."""
    return format_html('<link rel="stylesheet" href="{}">', static("css/wagtail.css")) 
开发者ID:ecds,项目名称:readux,代码行数:5,代码来源:wagtail_hooks.py

示例14: add_error_to_fields

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def add_error_to_fields(self, form, excluded=list()):
        for field in form.changed_data:
            if field not in excluded:
                form.add_error(field, _('Cannot update a static segment')) 
开发者ID:wagtail,项目名称:wagtail-personalisation,代码行数:6,代码来源:forms.py

示例15: media

# 需要导入模块: from django.contrib.staticfiles.templatetags import staticfiles [as 别名]
# 或者: from django.contrib.staticfiles.templatetags.staticfiles import static [as 别名]
def media(self):
        media = super(SegmentAdminForm, self).media
        media.add_js(
            [static('js/segment_form_control.js')]
        )
        return media 
开发者ID:wagtail,项目名称:wagtail-personalisation,代码行数:8,代码来源:forms.py


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