Home > Blockchain >  django admin form does not work in inline
django admin form does not work in inline

Time:10-30

This is my form

class LoginForm(ModelForm):
    class Meta:
        model = Login
        fields = '__all__'
        widgets = {
            'password': PasswordInput(),
        }

This is my inline

class LoginInline(admin.StackedInline):
    model = Login

This is my admin

class AppAdmin(admin.ModelAdmin):
    list_display = ('name', 'link_href')
    inlines = [LoginInline]

class LoginAdmin(admin.ModelAdmin):
    form = LoginForm

When I try to add login from login page, the password is correctly applied

enter image description here

But not from the app page using inline

enter image description here

How can I fix this ? I thought of adding another form for AppAdmin but the password field does not exist in App model only in Login model and I would like to know if there is a way to reference it inside another form

CodePudding user response:

I didn't test, but this should do it

class LoginInline(admin.StackedInline):
    form = LoginForm
    model = Login
  • Related