Previously I had admin.py as follows:
class ItemInline(admin.TabularInline):
model = Item
extra = 3
class EventAdmin(admin.ModelAdmin):
inlines = [ItemInline]
admin.site.register(Event, EventAdmin)
And it worked just fine but I have created 2 more models: OrderItem and Faq and I'm not sure how to register them
I've tried:
admin.register(Event, EventAdmin, OrderItem, Faq)(admin.ModelAdmin)
without luck, any help?
You have to do it several times:
admin.register(Event, EventAdmin)
admin.register(OrderItem, OrderItemAdmin)
admin.register(Faq, FaqAdmin)
Write admin classes for the other two models and write:
admin.site.register(Event, EventAdmin)
admin.site.register(OrderItem, OrderItemAdmin)
admin.site.register(Faq, FaqAdmin)
Here's the easy way!
from django.contrib import admin
from .models import *
#Register your models here.
myModels = [Category,Reader,AudioBook,AudioBookEpisode]
admin.site.register(myModels)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.