Can i get model field type from a model queryset in Django?
For example:
a
is b
model's queryset and the b
model has following fields:
Is there any way to get field g
's type from queryset a
?
thx.
A QuerySet is a collection of data from a database. A QuerySet is built up as a list of objects. QuerySets makes it easier to get the data you actually need, by allowing you to filter and order the data.
Fields in Django are the data types to store a particular type of data. For example, to store an integer, IntegerField would be used. These fields have in-built validation for a particular data type, that is you can not store “abc” in an IntegerField. Similarly, for other fields.
I have the answer:
a.model._meta.get_field('g').get_internal_type()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With