Задать вопрос

Тел: +7 965 3737 888

442

Просмотров

0

Ответов

Dynamically insert or append a value to an admin option, e.g. list_display or list_filter

<p>You can use this function to change an admin option dynamically.</p>
<p>For example, you can add a custom callable to <em>list_display</em> based on request, or if the current user has required permissions, as in the example below:</p>
class MyAdmin(admin.ModelAdmin):
    list_display = ('__unicode__', 'other_field')

    def changelist_view(self, request, extra_context=None):
        if request.user.is_superuser:
            add_dynamic_value(self, 'list_display', my_custom_callable)
        return super(MyAdmin, self).changelist_view(request, extra_context)

Вопрос полезен? Да0/Нет0
file_5173.py(874.0б)
None