Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 django 中获取模型字段的数量?
你应该看看模型的_meta属性:
_meta
In [1]: from django.contrib.auth.models import User In [2]: len(User._meta.fields) Out[2]: 11 In [3]: len(User._meta.many_to_many) Out[3]: 4