本文整理汇总了Python中django.forms.widgets.Media方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.Media方法的具体用法?Python widgets.Media怎么用?Python widgets.Media使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.widgets
的用法示例。
在下文中一共展示了widgets.Media方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def media(self):
# get the default js and css media
media = super().media
# remove the jQuery script manually
# this causes errors with datepicker-plus,
# see https://github.com/monim67/django-bootstrap-datepicker-plus/issues/42
# TODO this code patch can be removed in future,
# because of https://github.com/yourlabs/django-autocomplete-light/commit/e46300d
regex = re.compile(r"^admin/.*jquery(\.min)?\.js$")
filtered_js = [item for item in media._js if not regex.search(item)]
filtered_js.append("js/dal_fixes.js")
# add custom css
new_css = media._css
new_css["screen"].append("css/autocomplete-light.css")
return Media(js=tuple(filtered_js), css=new_css)
示例2: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def __init__(self, admin_view):
super(JSHeadPlugin, self).__init__(admin_view)
self._template = self.admin_view.base_template
self._media = Media()
示例3: media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def media(self):
"""
Provide a description of all media required to render the widgets on this form
"""
media = Media()
for field in self.fields.values():
media = media + field.widget.media
return media
示例4: media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def media(self):
js = ["core.js", "SelectBox.js", "SelectFilter2.js"]
return forms.Media(js=[static("admin/js/%s" % path) for path in js])
示例5: media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def media(self):
return Media(
css={"screen": _get_css(settings.DEBUG)}, js=_get_js(settings.DEBUG)
)
示例6: media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def media(self):
"""Return all media required to render the widgets on this form."""
media = Media()
for field in self.fields.values():
media = media + field.widget.media
return media
示例7: media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def media(self):
extra = '' if settings.DEBUG else '.min'
return widgets.Media(
js=(
'admin/js/vendor/jquery/jquery%s.js' % extra,
'admin/js/jquery.init.js',
'prettyjson/prettyjson.js',
),
css={
'all': ('prettyjson/prettyjson.css', )
},
)
示例8: get_media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def get_media(self):
try:
m = self.form_obj.media
except:
m = Media()
return super(ModelFormAdminView, self).get_media() + m + \
self.vendor('xadmin.page.form.js', 'xadmin.form.css')
示例9: _add_media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def _add_media(self, model_admin):
if not hasattr(model_admin, 'Media'):
raise ImproperlyConfigured('Add empty Media class to %s. Sorry about this bug.' % model_admin)
def _get_media(obj):
return Media(media=getattr(obj, 'Media', None))
media = _get_media(model_admin) + _get_media(AutocompleteFilter) + _get_media(self)
for name in MEDIA_TYPES:
setattr(model_admin.Media, name, getattr(media, "_" + name))
示例10: media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def media(self):
js = []
js.extend(settings.CONFIG['js'])
js.append(reverse(self.INIT_URL))
return Media(js=js, css=settings.CONFIG['css'])
示例11: _get_media
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Media [as 别名]
def _get_media(self):
"""
Provide a description of all media required to render the widgets on this form
"""
media = Media()
for field in self.fields.values():
media = media + field.widget.media
return media