擅长:python、mysql、java
<p>请参阅<a href="https://stackoverflow.com/questions/29738976/how-can-i-get-all-models-in-django-1-8">this</a>SO post。在</p>
<p><code>apps.get_models()</code>将返回所有已安装的型号。如果要查找特定应用程序的模型列表,请执行以下操作:</p>
<pre><code>from django.apps import apps
myapp = apps.get_app_config('myapp')
myapp.models #returns an OrderedDict
</code></pre>
<p>另外,作为参考,<a href="https://docs.djangoproject.com/en/2.0/_modules/django/apps/config/#AppConfig.get_models" rel="nofollow noreferrer">here's</a>是<code>get_models()</code>的源代码,以了解它是如何工作的</p>