metafield

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
In [16]: for i in Products._meta.fields:
....: print i.verbose_name
....:
....:
ID
name
model
catalog
brand
category
tag
description
price
image
thumbnail
for n in object_instance._meta.fields:
if n.verbose_name == 'RELATED_FOREIGNKEY_MODEL_VERBOSE_NAME':
#Model has FK relation
for n in object_instance._meta.many_to_many:
if n.verbose_name == 'RELATED_M2M_MODEL_VERBOSE_NAME:
#Model has m2m relation
#the ._meta.fields and ._meta.many_to_many are attributes of the model itself so:
Model._meta.fields and Model._meta.many_to_many work as well
# You can also simply introspect the instance itself to find out the
# model worked with:
object_instance._meta.verbose_name