47👍
My stupid mistake was that I had the inline class name inside quotes.
instead of:
class MyAdmin(admin.ModelAdmin):
inlines = [MyInlineAdmin]
it was:
class MyAdmin(admin.ModelAdmin):
inlines = ['MyInlineAdmin']
Total Cost:
- 2 Hours
- Some scratches on the laptop screen
- Less swimming today in the sea
2👍
I made a variation of the same mistake.
My inline was:
class MyModelInline(admin.StackedInline):
model = MyModel
But I referred to the inline by the model name, not the inline name:
@admin.register(OtherModel)
class OtherModelAdmin(admin.ModelAdmin):
inlines = [MyModel]
Whereas it should have been:
@admin.register(OtherModel)
class OtherModelAdmin(admin.ModelAdmin):
inlines = [MyModelInline]
That mistake was generating the following error:
ERRORS:
<class 'app_name.admin.OtherModelAdmin'>: (admin.E104) 'app_name.models.models_file.MyModel' must inherit from 'InlineModelAdmin'.
- Django – model unicode() show foreignkey object attribute
- Django (1.10) override AdminSite
- CSRF verification Failed – Referer is insecure while host is secure
- Bulk, partial updates with Django Rest Framework
- Django verbose request logging
1👍
Found the reason.
In actual code, which is not mine originally, names of models are the same as names of files they are placed in. Son at some step of checking Django (or python) detects inheritance of RemoteProductModel from LocalProductModel as error – like inheritance from file, not class-model. And after that it cannot work with it’s fields and of course RemotePurchaseAdmin cannot make import as inline as model if remote product.
It does not warn about inheritance error but raieses admin.E104 for admin.ModelAdmin, that tried to import incorrect model or inline.
Thanks everyone. Hope this will warn other developers from stupid mistakes.
- Cannot Log in to Django Admin Interface with Heroku Deployed App
- Django error cannot import name 'RemovedInDjango30Warning'
- Cannot load library libcairo
0👍
Yes the problem is the model name has changed, I solve this running makemigrations
and migrate
- Include a view in a template
- How do I execute an arbitrary script in the context of my Django project?
- Django success url using kwargs
0👍
It’s obvious once you see it…
Notice the accidental comma outside of the inlines
list? That triggers the warning too.