0

Getting project name without fields.

Hey.

 

I was looking for a way to get all projects and proejct names..

So after looking through the documentation i tried 

    all_projects = sg.find("Project",filters=[],fields=[])

to get all projects and project names but it turned out that this did not return the names. Only if i put "name" in the fields.

Why is that so? Can't I queue all data about "project" in a single request?

1 comment

  • 0
    Avatar
    KP

    Hi Mads,

    By default when you query for entities and don't specify any fields to be returned, you'll get what we call a standard entity hash back. It looks like this:

    {'type':'Project', 'id':123}

    You can get more fields returned (like 'name') by including them in the 'fields' parameter as you discovered. We don't include all fields by default because this is generally a lot of unneeded information. Scripts tend to be after specific field values, not all of them. So in order to save on processing power and network bandwidth, we only provide what is requested. Imagine a query on Tasks at the end of a project... if you have a lot of Task fields, and 1000, 10000, 100000 Tasks... that's a lot of information that may not be necessary if you're only looking for the status for example.

    From the API you can see what fields are available by using the following method:

    project_fields = sg.schema_field_read('Project')

    This will give you a dictionary that has all of the fields on Project as keys, and their values contain more dictionary formatted info about the fields themselves. You can read more about it in our API docs: https://github.com/shotgunsoftware/python-api/wiki/Reference%3A-Methods#wiki-schema_field_read

Please sign in to leave a comment.