Django — MediaDefiningClass object is not iterable

For me, 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. That’s one good way to think about it.

17 Comments

  1. Carl says:

    Thanks for the tip – this was a confusing error.

  2. Thanks a lot, a really helpful post. And a nice idea how not to confuse the order.

  3. sparkle says:

    Thanks a lot, dude. It was really helpful

  4. paravozovich says:

    Thank you! You save my time and nerves 🙂

  5. Redevil says:

    thanks 🙂

  6. Pierre Geier says:

    I got this error too, but had no idea what was causing it, because nothing looked wrong in my admin.py. It’s not the problem that drives you insane, it’s finding the resolution for it 🙂

  7. Kamil says:

    Thanks, that’s goot tip. I forgot to add “Admin” to name of the class.

  8. Will Farley says:

    This was at the top of the search for “‘MediaDefiningClass’ object is not iterable” and is the obvious solution! Thanks, it was nice not having to stress over a an Error Page for once!

  9. rafal says:

    thanks man

  10. Bruce Davis says:

    Thanks for posting this, it helped me

  11. Gadjimurad says:

    Thank you for article.It’s very useful.

  12. Ali says:

    That solved the problem, thanks

  13. Kirk DeBaets says:

    Thank you for posting this! Nearly pulled all of my hair out!!

Leave a reply to Gadjimurad Cancel reply