Python django.forms 模块,Media() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用django.forms.Media()

项目:django-admin-reports    作者:simplyopen-it    | 项目源码 | 文件源码
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])
项目:django-clubhouse    作者:chazmead    | 项目源码 | 文件源码
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)
项目:django-clubhouse    作者:chazmead    | 项目源码 | 文件源码
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]}
        )
项目:django-admin-json-editor    作者:abogushov    | 项目源码 | 文件源码
def media(self):
        css = {
            'all': [
                'django_admin_json_editor/bootstrap/css/bootstrap.min.css',
                'django_admin_json_editor/fontawesome/css/font-awesome.min.css',
                'django_admin_json_editor/style.css',
            ]
        }
        js = [
            'django_admin_json_editor/jquery/jquery.min.js',
            'django_admin_json_editor/bootstrap/js/bootstrap.min.js',
            'django_admin_json_editor/jsoneditor/jsoneditor.min.js',
        ]
        if self._sceditor:
            css['all'].append('django_admin_json_editor/sceditor/themes/default.min.css')
            js.append('django_admin_json_editor/sceditor/jquery.sceditor.bbcode.min.js')
        return forms.Media(css=css, js=js)
项目:django-prosemirror    作者:zakdoek    | 项目源码 | 文件源码
def _media(self):
        """
        Include media
        """
        js = (
            staticfiles_storage.url("prosemirror/widget.min.js"),
        )

        css = {
            "all": (
                staticfiles_storage.url(
                    "prosemirror/widget.min.css"),
            )
        }
        return forms.Media(css=css, js=js)
项目:mendelmd    作者:raonyguimaraes    | 项目源码 | 文件源码
def _get_media(self):
        """
        Construct Media as a dynamic property.

        .. Note:: For more information visit
            https://docs.djangoproject.com/en/1.8/topics/forms/media/#media-as-a-dynamic-property
        """
        return forms.Media(
            js=(settings.SELECT2_JS, 'django_select2/django_select2.js'),
            css={'screen': (settings.SELECT2_CSS,)}
        )
项目:ecs_sclm    作者:meaningful    | 项目源码 | 文件源码
def media(self):
        return forms.Media(js=[static("suit/js/jquery.autosize-min.js")])
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def media(self):
        js = ["core.js", "SelectBox.js", "SelectFilter2.js"]
        return forms.Media(js=[static("admin/js/%s" % path) for path in js])
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=[static("admin/js/%s" % path) for path in js])
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=[static("admin/js/%s" % path) for path in js])
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
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()
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def media(self):
        extra = '' if settings.DEBUG else '.min'
        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])
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def media(self):
        js = ["core.js", "SelectBox.js", "SelectFilter2.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
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=['admin/js/%s' % url for url in js])
        return forms.Media()
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def media(self):
        extra = '' if settings.DEBUG else '.min'
        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=['admin/js/%s' % url for url in js])
项目:django-happenings    作者:natgeosociety    | 项目源码 | 文件源码
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)
项目:django-admin-rangefilter    作者:silentsokolov    | 项目源码 | 文件源码
def _get_media():
        js = [
            'calendar.js',
            'admin/DateTimeShortcuts.js',
        ]
        css = [
            'widgets.css',
        ]
        return forms.Media(
            js=['admin/js/%s' % url for url in js],
            css={'all': ['admin/css/%s' % path for path in css]}
        )
项目:blog_django    作者:chnpmy    | 项目源码 | 文件源码
def media(self):
        return forms.Media()
项目:blog_django    作者:chnpmy    | 项目源码 | 文件源码
def get_media(self):
        return forms.Media()
项目:blog_django    作者:chnpmy    | 项目源码 | 文件源码
def vendor(*tags):
    media = Media()
    for tag in tags:
        file_type = tag.split('.')[-1]
        files = xstatic(tag)
        if file_type == 'js':
            media.add_js(files)
        elif file_type == 'css':
            media.add_css({'screen': files})
    return media
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def media(self):
        js = ["core.js", "SelectBox.js", "SelectFilter2.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
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=['admin/js/%s' % url for url in js])
        return forms.Media()
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def media(self):
        extra = '' if settings.DEBUG else '.min'
        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=['admin/js/%s' % url for url in js])
项目:DCRM    作者:82Flex    | 项目源码 | 文件源码
def media(self):
        return forms.Media(js=('suit/js/autosize.min.js',))
项目:wagtailmarkdownblock    作者:FlipperPA    | 项目源码 | 文件源码
def media(self):
        return Media(
            js=[
                'plugins/simplemde/simplemde.min.js',
                'plugins/simplemde/simplemde.attach.js'
            ],
            css={
                'all': ('plugins/simplemde/simplemde.min.css',)
            }
        )
项目:dream_blog    作者:fanlion    | 项目源码 | 文件源码
def media(self):
        return forms.Media()
项目:dream_blog    作者:fanlion    | 项目源码 | 文件源码
def get_media(self):
        return forms.Media()
项目:dream_blog    作者:fanlion    | 项目源码 | 文件源码
def vendor(*tags):
    media = Media()
    for tag in tags:
        file_type = tag.split('.')[-1]
        files = xstatic(tag)
        if file_type == 'js':
            media.add_js(files)
        elif file_type == 'css':
            media.add_css({'screen': files})
    return media
项目:MxOnline    作者:myTeemo    | 项目源码 | 文件源码
def media(self):
        return forms.Media()
项目:MxOnline    作者:myTeemo    | 项目源码 | 文件源码
def get_media(self):
        return forms.Media()
项目:MxOnline    作者:myTeemo    | 项目源码 | 文件源码
def vendor(*tags):
    media = Media()
    for tag in tags:
        file_type = tag.split('.')[-1]
        files = xstatic(tag)
        if file_type == 'js':
            media.add_js(files)
        elif file_type == 'css':
            media.add_css({'screen': files})
    return media
项目:django-admin-ordering    作者:matthiask    | 项目源码 | 文件源码
def media(self):
        if not isinstance(self, InlineModelAdmin):
            context = {'field': self.ordering_field}
        else:
            if not self.fk_name:
                raise ImproperlyConfigured(
                    '%r requires a `fk_name` -- we are too dumb/lazy to'
                    ' determine it ourselves. Thanks!' % (self.__class__))

            context = {
                'field': self.ordering_field,
                'prefix': get_default_formset_prefix(
                    self.parent_model, self.model, self.fk_name),
                'stacked': isinstance(self, admin.StackedInline),
                'tabular': isinstance(self, admin.TabularInline),
            }

        return super(OrderableAdmin, self).media + forms.Media(
            css={'all': (
                'admin_ordering/admin_ordering.css',
            )},
            js=[
                'admin_ordering/jquery-ui-1.11.4.custom.min.js',
                JS('admin_ordering/admin_ordering.js', {
                    'class': 'admin-ordering-context',
                    'data-context': json.dumps(context),
                }),
            ],
        )
项目:djangoblog    作者:liuhuipy    | 项目源码 | 文件源码
def media(self):
        return forms.Media()
项目:djangoblog    作者:liuhuipy    | 项目源码 | 文件源码
def get_media(self):
        return forms.Media()
项目:djangoblog    作者:liuhuipy    | 项目源码 | 文件源码
def vendor(*tags):
    media = Media()
    for tag in tags:
        file_type = tag.split('.')[-1]
        files = xstatic(tag)
        if file_type == 'js':
            media.add_js(files)
        elif file_type == 'css':
            media.add_css({'screen': files})
    return media
项目:sdining    作者:Lurance    | 项目源码 | 文件源码
def media(self):
        return forms.Media()
项目:sdining    作者:Lurance    | 项目源码 | 文件源码
def get_media(self):
        return forms.Media()
项目:sdining    作者:Lurance    | 项目源码 | 文件源码
def vendor(*tags):
    media = Media()
    for tag in tags:
        file_type = tag.split('.')[-1]
        files = xstatic(tag)
        if file_type == 'js':
            media.add_js(files)
        elif file_type == 'css':
            media.add_css({'screen': files})
    return media
项目:wagtailblocks_cards    作者:alexgleason    | 项目源码 | 文件源码
def media(self):
        parent_media = super(CardsBlock, self).media
        cards_css = {
            'screen': (static('wagtailblocks_cards/css/wagtailblocks_cards.css'),)
        }
        cards_media = forms.Media(css=cards_css)
        return parent_media + cards_media
项目:tumanov_castleoaks    作者:Roamdev    | 项目源码 | 文件源码
def media(self):
        return super().media + forms.Media(
            js=(
                'admin/js/customize.js',
            ),
        )
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def media(self):
        js = ["core.js", "SelectBox.js", "SelectFilter2.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def media(self):
        js = ["calendar.js", "admin/DateTimeShortcuts.js"]
        return forms.Media(js=["admin/js/%s" % path for path in js])
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
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=['admin/js/%s' % url for url in js])
        return forms.Media()
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def media(self):
        extra = '' if settings.DEBUG else '.min'
        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=['admin/js/%s' % url for url in js])
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
def media(self):
        js = ["core.js", "SelectBox.js", "SelectFilter2.js"]
        return forms.Media(js=[static("admin/js/%s" % path) for path in js])