Can i get model field type from a model queryset in Django?
我可以从Django中的模型查询集中获取模型字段类型吗?
For example: a
is b
model's queryset and the b
model has following fields:
例如:a是b模型的查询集,b模型具有以下字段:
- f:charfield
- F:charfield
- g:foreignkey
- G:外键
- h:manytomany
- H:多对多
Is there any way to get field g
's type from queryset a
? thx.
有没有办法从queryset a获取字段g的类型?谢谢。
1 个解决方案
#1
34
I have the answer:
我有答案:
a.model._meta.get_field('g').get_internal_type()
#1
34
I have the answer:
我有答案:
a.model._meta.get_field('g').get_internal_type()