[Django]-Displaying Table using models in Django admin

6👍

You may want either AdminInline or list_editable Django features:

  1. If you have linked models, say a Project and a Product, which is linked to Project, you can make your product editable as inlines:

    class ProductInline(admin.TabularInline):
        model = Product
    
    class Project(admin.ModelAdmin):
        model = Project
        inlines = [ProductInline, ]
    
  2. If you have a standalone table, say, Product, you can make its list to be editable:

    class ProductAdmin(admin.ModelAdmin):
        model = Product
        list_display = ['quantity', 'description', 'tax_rate', ] 
        list_editable = ['quantity', 'description', 'tax_rate', ] 
    

Leave a comment