[Fixed]-Admin.py: "model = Thing" ,what does this code mean?if without it what gonna happen?

1👍

Setting a model attribute on the ModelAdmin class will have no effect. You can safely remove that line from your code.

In the Django admin, you specify the model when you call admin.site.register(), or by using the register decorator. This allows you to use the same model admin class for more than one model.

admin.site.register(Thing, ThingAdmin)
admin.site.register(OtherThing, ThingAdmin)

As Jon pointed out in the comments, you do need to specify the model for InlineModelAdmin objects.

Leave a comment