Trying to use Inlines to get customised view at Admin Dashboard. Below is the code
from django.contrib import admin # noqa
from oscar.core.loading import get_model
from oscar.apps.catalogue.admin import *
CategoryAttribute = get_model('catalogue', 'CategoryAttribute')
CategoryAttributeValue = get_model('catalogue', 'CategoryAttributeValue')
Category = get_model('catalogue', 'Category')
class CategoryAttributeInline(admin.TabularInline):
model = CategoryAttributeValue
fk_name = 'category'
extra = 1
class CategoryAdmin(admin.ModelAdmin):
inlines = [CategoryAttributeInline,]
admin.site.register(CategoryAttributeValue)
admin.site.register(CategoryAttribute)
admin.site.register(Category, CategoryAdmin)
The error I am getting is
TypeError: 'MediaDefiningClass' object is not iterable
What is the problem in my code ?
sometimes the cause of this error was sending arguments to the register function in the wrong order.
Check the order of registering a ModelAdmin: it’s the model class first, then the ModelAdmin class.
Example: admin.site.register(Model, ModelAdmin)
I suppose naturally the second one has to be the ModelAdmin since register(MyModel) works as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With