azavea/OTM2 — pull request #183 by ahinz (2013-08-14 13:53:49+00:00)
Title: Add support for searching UDF headers

This commit adds general support for filter on udf fields using standard
django filter syntax with the addition of a prefix:

```
Plot.objects.filter(**{'udf:nickname': 'stumpy'})
```

This means that search queries can include the udf prefix on fields and
things should 'just work':

```
{'tree.udf:age': {'MIN': 5, 'MAX': 10}}
```

In general, the commit provides machinery for django to generate a valid
where and order by clause. For example, something like:

```
Plot.objects.filter(**{'udf:Plant Date': datetime(2000,1,2)})
```

Transforms it SQL like:

```
("treemap_plot"."udf_scalar_values"->'Plant Date')::timestamp ==
'2000-01-02'::timestamp
```

In addition to filtering ordering is also supported. When ordering by a
udf the order by statement must include the model prefix. The following
are valid order by definitions:

```
Plot.udf:Nickname
-Tree.udf:Secret ID
```

Since we don't know the datatype of a sort field we cannot cast it.
Dates will sort correctly since dates are lexicographically ordered.
Numbers will not.