Search code examples
pythonflaskflask-admineditview

Need to modify the edit view in Flask admin


I am working on Flask admin. Please check the following. enter image description here

I need to edit the existing record using that edit button shown above.

My edit view is as follow : enter image description here

I need to add a field in edit view whose value appears in the image column shown in the second image.

Any help is appreciable.


Solution

  • Just add a field in your data model after the Image field.

    class Restaurant(db.Model):
    
        # ...
        image = db.Column()
        field_extra = db.Column()
    

    In Flask-Admin, use column_list to specify the field you want to display:

    class RestaurantModelView(ModelView):
    
        column_list = ["id", "title", "course", "image"]  # fields list except `field_extra`