Created
May 24, 2022 08:21
-
-
Save timurbakibayev/c598fd80aae07829a65b22952bc98215 to your computer and use it in GitHub Desktop.
StackedInline Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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