OSU-Net/cyder — pull request #470 by zeeman (2013-11-27 01:25:28+00:00)
Title: Fix attribute/view filtering.

This pull request is intended to fix an issue which made it very annoying to filter by attributes or views. In the database, attributes and views are associated with their relevant records through foreign keys, but in the API they are presented as string representations (for example, instead of a URL to some attribute endpoint, you would just see "Hardware type"). However, due to how filtering works (directly processing the query string parameters to Django queries), this leads to a confusing bug if you try to do something like `/api/v1/core/system/attributes/?i:attribute=hardware+type`, because this creates a query like `SystemAV.objects.filter(attribute="hardware type")`, which fails since you're trying to specify "hardware type" as the foreign key to the attribute model. This fix overcomes that by simply appending `__name` to any query ending in `attribute` or `views`. That's pretty ugly, but I couldn't think of a better way that didn't involve a substantial overhaul of how filtering works, so I think it'll do for now.