Python django.contrib.admin.widgets 模块,AdminTextareaWidget() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用django.contrib.admin.widgets.AdminTextareaWidget()

项目:django-happenings    作者:natgeosociety    | 项目源码 | 文件源码
def render(self, name, value, attrs=None):
        if attrs is None:
            attrs = {}
        # it's called "original" because it will be replaced by a copy
        attrs['class'] = 'hstore-original-textarea'

        # get default HTML from AdminTextareaWidget
        html = super(BaseAdminHStoreWidget, self).render(name, value, attrs)

        # prepare template context
        template_context = Context({
            'field_name': name,
            'STATIC_URL': settings.STATIC_URL,
            'use_svg': django.VERSION >= (1, 9),  # use svg icons if django >= 1.9
        })
        # get template object
        template = get_template('happenings/hstore_%s_widget.html' % self.admin_style)
        # render additional html
        additional_html = template.render(template_context)

        # append additional HTML and mark as safe
        html = html + additional_html
        html = mark_safe(html)

        return html
项目:django-happenings    作者:natgeosociety    | 项目源码 | 文件源码
def render(self, name, value, attrs=None):
        # get default HTML from AdminTextareaWidget
        html = super(RecurringEventWidget, self).render(name, value, attrs)

        if '__prefix__' in name:
            return mark_safe(html)

        data = {
            "url": reverse('admin:happenings_get_occurrences'),
            "field_id": attrs['id'],
            "date_field": attrs['id'].replace(self.text_field, self.start_date_field)
        }
        additional_html = self.js_tmpl % data

        # append additional HTML and mark as safe
        html = html + additional_html
        html = mark_safe(html)

        return html
项目:django-prosemirror    作者:zakdoek    | 项目源码 | 文件源码
def formfield(self, **kwargs):
        """
        Construct form field
        """
        defaults = {"widget": self.widget}
        defaults.update(kwargs)

        if defaults["widget"] == admin_widgets.AdminTextareaWidget:
            defaults["widget"] = self.widget
        return super(ProseMirrorField, self).formfield(**defaults)