本文整理汇总了Python中django.contrib.admin.templatetags.admin_static.static方法的典型用法代码示例。如果您正苦于以下问题:Python admin_static.static方法的具体用法?Python admin_static.static怎么用?Python admin_static.static使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admin.templatetags.admin_static
的用法示例。
在下文中一共展示了admin_static.static方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def media(self):
# taken from django.contrib.admin.options ModelAdmin
extra = '' if settings.DEBUG else '.min'
# if VERSION <= (1, 8):
if StrictVersion(get_version()) < StrictVersion('1.9'):
js = [
'core.js',
'admin/RelatedObjectLookups.js',
'jquery%s.js' % extra,
'jquery.init.js',
]
else:
js = [
'core.js',
'vendor/jquery/jquery%s.js' % extra,
'jquery.init.js',
'admin/RelatedObjectLookups.js',
'actions%s.js' % extra,
'urlify.js',
'prepopulate%s.js' % extra,
'vendor/xregexp/xregexp%s.js' % extra,
]
return forms.Media(js=[static('admin/js/%s' % url) for url in js])
示例2: _media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def _media(self):
js = [
"image_cropping/js/jquery.Jcrop.min.js",
"image_cropping/image_cropping.js",
os.path.join(URL_FILEBROWSER_MEDIA, 'js/AddFileBrowser.js')
]
js = [admin_static.static(path) for path in js]
if settings.IMAGE_CROPPING_JQUERY_URL:
js.insert(0, settings.IMAGE_CROPPING_JQUERY_URL)
css = [
"image_cropping/css/jquery.Jcrop.min.css",
"image_cropping/css/image_cropping.css",
]
css = {'all': [admin_static.static(path) for path in css]}
return forms.Media(css=css, js=js)
示例3: media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def media(self):
extra = '' if settings.DEBUG else '.min'
js = [
'core.js',
'admin/RelatedObjectLookups.js',
'jquery%s.js' % extra,
'jquery.init.js'
]
css = [
'block_admin.css'
]
# if self.actions is not None:
# js.append('actions%s.js' % extra)
# if self.prepopulated_fields:
# js.extend(['urlify.js', 'prepopulate%s.js' % extra])
return forms.Media(
js=[static('admin/js/%s' % url) for url in js],
css={'all': [static('admin/css/%s' % url) for url in css]}
)
示例4: render
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def render(self, name, value, attrs=None, choices=()):
output = [super(ApplicationConfigSelect, self).render(name, value, attrs, choices)]
output.append('<script>\n')
output.append('var apphooks_configuration = {\n')
for application, cms_app in self.app_configs.items():
output.append("'%s': [%s]," % (application, ",".join(["['%s', '%s']" % (config.pk, force_text(config)) for config in cms_app.get_configs()])))
output.append('\n};\n')
output.append('var apphooks_configuration_url = {\n')
for application, cms_app in self.app_configs.items():
output.append("'%s': '%s'," % (application, cms_app.get_config_add_url()))
output.append('\n};\n')
output.append('var apphooks_configuration_value = \'%s\';\n' % value)
output.append('</script>')
related_url = ''
output.append('<a href="%s" class="add-another" id="add_%s" onclick="return showAddAnotherPopup(this);"> '
% (related_url, name))
output.append('<img src="%s" width="10" height="10" alt="%s"/></a>'
% (static('admin/img/icon_addlink.gif'), _('Add Another')))
return mark_safe(''.join(output))
示例5: init_add_fields
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def init_add_fields(self):
for field_name, url_name in getattr(self.Meta, 'add_fields', {}).items():
try:
url = reverse(url_name)
except NoReverseMatch:
url = reverse(url_name, args=[self.instance.pk])
# self.fields[field_name].label_suffix = "" # suffix not supported by django-crispy-forms
url += '?auto_select_field=' + field_name
self.fields[field_name].label += self.field_label_addon.format(
url, static('admin/img/icon-addlink.svg'), 'Add'
)
示例6: media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def media(self):
return forms.Media(js=[static("suit/js/jquery.autosize-min.js")])
示例7: media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def media(self):
js = ["core.js", "SelectBox.js", "SelectFilter2.js"]
return forms.Media(js=[static("admin/js/%s" % path) for path in js])
示例8: _media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def _media(self):
if 'collapse' in self.classes:
extra = '' if settings.DEBUG else '.min'
js = ['vendor/jquery/jquery%s.js' % extra,
'jquery.init.js',
'collapse%s.js' % extra]
return forms.Media(js=[static('admin/js/%s' % url) for url in js])
return forms.Media()
示例9: _boolean_icon
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def _boolean_icon(field_val):
icon_url = static('admin/img/icon-%s.svg' %
{True: 'yes', False: 'no', None: 'unknown'}[field_val])
return format_html('<img src="{}" alt="{}" />', icon_url, field_val)
示例10: media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def media(self):
extra = '' if settings.DEBUG else '.min'
js = ['vendor/jquery/jquery%s.js' % extra, 'jquery.init.js',
'inlines%s.js' % extra]
if self.filter_vertical or self.filter_horizontal:
js.extend(['SelectBox.js', 'SelectFilter2.js'])
return forms.Media(js=[static('admin/js/%s' % url) for url in js])
示例11: media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def media(self):
internal_js = [
"happenings/underscore-min.js",
"happenings/hstore-widget.js"
]
js = [static(path) for path in internal_js]
return forms.Media(js=js)
示例12: render
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def render(self, name, value, attrs=None, choices=()):
if attrs is None:
attrs = {}
attrs['class'] = 'selectfilter'
if self.is_stacked:
attrs['class'] += 'stacked'
output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)]
output.append('<script type="text/javascript">addEvent(window, "load", function(e) {')
# TODO: "id_" is hard-coded here. This should instead use the correct
# API to determine the ID dynamically.
output.append('SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n'
% (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), static('admin/')))
return mark_safe(''.join(output))
示例13: _boolean_icon
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def _boolean_icon(field_val):
icon_url = static('admin/img/icon-%s.gif' %
{True: 'yes', False: 'no', None: 'unknown'}[field_val])
return format_html('<img src="{}" alt="{}" />', icon_url, field_val)
示例14: media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def media(self):
extra = '' if settings.DEBUG else '.min'
js = [
'core.js',
'admin/RelatedObjectLookups.js',
'jquery%s.js' % extra,
'jquery.init.js'
]
if self.actions is not None:
js.append('actions%s.js' % extra)
if self.prepopulated_fields:
js.extend(['urlify.js', 'prepopulate%s.js' % extra])
return forms.Media(js=[static('admin/js/%s' % url) for url in js])
示例15: _media
# 需要导入模块: from django.contrib.admin.templatetags import admin_static [as 别名]
# 或者: from django.contrib.admin.templatetags.admin_static import static [as 别名]
def _media(self):
if 'collapse' in self.classes:
extra = '' if settings.DEBUG else '.min'
js = ['jquery%s.js' % extra,
'jquery.init.js',
'collapse%s.js' % extra]
return forms.Media(js=[static('admin/js/%s' % url) for url in js])
return forms.Media()