Reduce the query count by one per page when using SiteConfiguration.

SiteConfiguration always looked up self.site to build the cache key,
which did a query for the proper Site. However, in every realistic case,
that's going to be equal to Site.objects.get_current(), which either
will have been fetched at that point, or soon would be anyway.

We now fetch this and, if it's the ID we expect, we set the current
instance to it. That reduces an unnecessary query per request.
Merge branch 'release-0.7.x'
Fix inlineEditor dirty detection with hasRawValue.

When hasRawValue is true, and the current value has any otherwise
HTML-escapable content, the field would always be dirty after any key
press. Simply moving the cursor would mark it as dirty.

We now only htmlEncode the current value if hasRawValue is false.
Fix auto-sizing the inlineEditor when forcing an auto-size.

When editing Markdown in Review Board, the inlineEditor will sometimes
size itself too short. This seemed to be due to telling it to animate
when forcing, which was probably not what we wanted. By forcing
animation to be off in this case, the sizing matches what is expected.
Don't query for objects in a response when we know the count is 0.

When building a paginated webapi response, we would always perform a
query for the count and a query for the objects. The latter query is
pointless if the count is 0, so only do it if we know there are objects
to fetch.
Cache calculated values when we know they won't change.

We frequently get the name and name_plural properties of an API
resource. In the case where a resource doesn't explicitly set them, we
calculate them, and we do this every time it's accessed, even though
it'll never change. Instead, cache these values and only calculate them
once.
Merge branch 'release-0.7.x'
Allow a custom ID field to be passed to WebAPIResource.get_object.

There's a case in Review Board where a resource is overriding
WebAPIResource.get_object in order to change which ID field a particular
ID is matched against. That makes it easy to get out of sync regarding
logic and optimizations.

get_object now takes an optional id_field argument. If specified, it
will use that field for the lookup. Subclasses can then make use of
the real get_object and just pass in a different value for id_field.
Remove backwards-compatibility for allowed_{item,list}_mimetypes.

In 0.6.x, we deprecated the allowed_{item,list}_mimetypes variables, in
support of the consolidated allowed_mimetypes list. For compatibility,
we built up the new list from the old ones, if they were set. While not
a ton of work, it was extra work we didn't need to do, and extra
storage.

Support for those old lists are now gone. Clients must use
allowed_mimetypes.

Along with this, allowed_mimetypes entries no longer need to have both
an 'item' and a 'list' entry. They default to None.
Optimize queries when fetching objects in the API.

Fetching lists could be wildly inefficient in terms of query counts, due
to related objects for each object being fetched when serializing items.
select_related() didn't help us here, as it can't traverse
ManyToManyFields.

We now use Django's somewhat new prefetch_related() to fetch all related
fields that we know will be serialized when getting a list resource. We
start off by building and caching a list of fields, based on the
resource's fields dictionary, and using that when fetching the list.

A new _get_queryset method handles this logic. It's called internally
instead of calling get_queryset() and tacking on select_related().

This dramatically cuts down on some query counts. It doesn't make as big
a difference in most unit tests, as they don't tend to create large
batches of objects for testing, but in real-world usage, there's a
noticeable difference.