[Answered ]-Why the change of the widget inside the get_form method does not reflect the change in the Django admin site

1👍

✅

The easiest way is likely to specify a form with:

class PostForm(forms.ModelForm):
    class Meta:
        model = Post
        fields = '__all__'
        labels = {'image_in_base64 ': 'Main image of the post'}
        widgets = {'image_in_base64': forms.FileInput()}

and then plug this into the ModelAdmin:

from django.contrib import admin


class MyAdminPost(admin.ModelAdmin):
    form = PostForm

Leave a comment