Finding the fields for an entity

Not sure if this is documented, I hope it helps someone.

If you want to find what fields correspond to the UI labels for a given entity, you can lookup it''s schema:


sg = Shotgun(base_url, script_name, script_key)

# get the schema of entity 'Shot'

sch = sg.schema_field_read('Shot')

for k in sorted(sch.keys()):
...   print 'field:%s, UI label:%s' %(k, sch[k]['name']['value'])


  • 0
    Mihail Temelkov

    this way it's easy to see that internal field 'code' corresponds to UI name 'Shot Number'

  • 0
    Mihail Temelkov

    If you want the listing to be sorted based on the UI labels, you can do this:

    >>> labels_fields_map = {}
    >>> for field in sch.keys():
    ...   label = sch[field]['name']['value']
    ...   labels_fields_map[label] = field
    >>> for label in sorted(labels_fields_map.keys()):
    ...   print label, labels_fields_map[label]