MediaDefiningClass object not repeating?

Trying to use Inlines to get an individual view in the admin control panel. 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 get is TypeError: 'MediaDefiningClass' object is not iterable

What is the problem in my code?

+5
source share
1 answer

sometimes the reason for this error was sending arguments to the registration function in the wrong order.

Check the registration order of ModelAdmin: first its model class, then the ModelAdmin class.

Example: admin.site.register (Model, ModelAdmin)

I suppose, naturally, the second should be ModelAdmin, since the register (MyModel) also works.

0
source

All Articles