Пример #1
0
    def render(self, obj):
        text = helper.call_or_get(obj, self.attr)
        p_params = {}
        for key in self.params.keys():
            p_params[key] = helper.call_or_get(obj, self.params[key])

        return '<a href="%s">%s</a>' % (reverse('admin:%s_%s_changelist' %
                                                (self.app, self.model)) + '?' +
                                        urlencode(p_params), text)
Пример #2
0
    def render(self, obj):
        text = helper.call_or_get(obj, self.attr)
        p_params = {}
        for key in self.params.keys():
            p_params[key] = helper.call_or_get(obj, self.params[key])

        return '<a href="%s">%s</a>' % (
            reverse('admin:%s_%s_changelist' % (self.app, self.model)) + '?' + urlencode(p_params),
            text
        )
Пример #3
0
    def render(self, obj):
        ref = helper.call_or_get(obj, self.attr, self.default)
        display = None
        if self.display:
            display = helper.call_or_get(obj, self.display, self.default)

        if isinstance(ref, Model):
            return '<a href="%s">%s</a>' % (reverse(
                admin_urlname(ref._meta, 'change'), args=(ref.pk, )), display
                                            or ref)

        return self.default
Пример #4
0
    def render(self, obj):
        src = helper.call_or_get(obj, self.attr)

        if isinstance(src, ModelImageField):
            src = settings.MEDIA_URL + src

        p_params = {}
        for key in self.params.keys():
            p_params[key] = helper.call_or_get(obj, self.params[key])

        p_params['src'] = src

        return '<img%s/>' % (flatatt(p_params))
Пример #5
0
    def render(self, obj):
        src = helper.call_or_get(obj, self.attr)

        if isinstance(src, ModelImageField):
            src = settings.MEDIA_URL + src

        p_params = {}
        for key in self.params.keys():
            p_params[key] = helper.call_or_get(obj, self.params[key])

        p_params['src'] = src

        return '<img%s/>' % (
            flatatt(p_params)
        )
Пример #6
0
    def render(self, obj):
        ref = helper.call_or_get(obj, self.attr, self.default)
        display = None
        if self.display:
            display = helper.call_or_get(obj, self.display, self.default)

        if isinstance(ref, Model):
            return '<a href="%s">%s</a>' % (
                reverse(
                    admin_urlname(ref._meta, 'change'),
                    args=(ref.pk,)
                ),
                display or ref
            )

        return self.default
Пример #7
0
 def render(self, obj):
     return helper.call_or_get(obj, self.attr, self.default)
Пример #8
0
 def render(self, obj):
     return helper.call_or_get(obj, self.attr, self.default)