Skip to content

Instantly share code, notes, and snippets.

@timurbakibayev
Created May 24, 2022 08:21
Show Gist options
  • Save timurbakibayev/c598fd80aae07829a65b22952bc98215 to your computer and use it in GitHub Desktop.
Save timurbakibayev/c598fd80aae07829a65b22952bc98215 to your computer and use it in GitHub Desktop.
StackedInline Example
from django.contrib import admin
from shop.models import Cart, Item, CartItem
class ItemInline(admin.StackedInline):
model = CartItem
extra = 5
class CartAdmin(admin.ModelAdmin):
inlines = [ItemInline]
list_display = ["created", "total_price", "paid"]
admin.site.register(Cart, CartAdmin)
admin.site.register(Item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment