Django admin inline module is not rendering form's widget

Viewed 145

I tried to use a custom widget of the library django-ace and pretty-json, but I don't know why it's not rendering these widgets when I put it into the inline module and it's rendering a texarea by default.

I think it's an issue of django inline module, but I don't know if someone has a recommendation to solve this.

from django_ace import AceWidget
from django import forms
from django.forms import formset_factory, BaseInlineFormSet
from prettyjson import PrettyJSONWidget
from django.contrib import admin

class StatementForm(forms.ModelForm):
    class Meta:
        model = Statements
        fields = ['query', 'executed', 'logs']
        widgets = {
            'logs': PrettyJSONWidget(attrs={'initial': 'parsed'}),
            'query': AceWidget(mode='sql')
        }

StatementFormSet = formset_factory(StatementForm, formset=BaseInlineFormSet, can_order=True)

class StatementTabularInline(admin.StackedInline):
    model = Statements
    formset = StatementFormSet
    readonly_fields = ['executed', 'logs', ]

@admin.register(Ticket)
class TicketAdmin(admin.ModelAdmin):
    inlines = [StatementTabularInline]

links:

result: result of the render of the form

0 Answers
Related