更新时间:2023-10-11 17:12:58
我通过@arie 的链接解决了这个问题(对于 django < 1.8):
I figured it out with @arie's link (for django < 1.8):
from django.contrib import admin
from django.db.models import get_models, get_app
for model in get_models(get_app('doors')):
admin.site.register(model)
但我想知道我是否可以在没有 get_app
的情况下做到这一点...难道代码不能聪明到知道自己的应用程序的名称吗?
But I wonder if I can do this without get_app
... Couldn't the code be smart enough to know the name of its own app?