Closed rpkilby closed 8 years ago
Hey @carltongibson - this has been reworked into a separate PR that is not dependent on the label/form improvements. It would be great to get it merged into the 0.15 release, as it also has a number of deprecations.
Hey @carltongibson, I wanted to submit this PR internally to the label improvements branch, due to the growing scope creep of the original PR (label improvements, reworked ordering, deprecations, docs, etc...). Want to keep that PR from becoming un-reviewable. This makes the label improvements branch fully compatible with the existing ordering features, except for
get_order_by
andget_ordering_field
(refactored, no longer invoked).The objective is to completely deprecate the ordering features on the FilterSet, instead encouraging the use of an explicitly declared ordering filter. In theory,
order_by
and the refactoredget_ordering_filter
could be kept, however I think it's better to remove it. The existing behavior oforder_by
is just not compatible with too many use cases. Maybe the deprecation could become a behavior change toorder_by
?Details: In short, this completely reworks ordering into two ordering filters.
OrderingFilter
is the base filter that allows backwards compatibility with the existing feature set.fields
argument allows users to alias the underlying field names. eg, account => usernameAutoOrderingFilter
builds onOrderingFilter
to reduce some verbosity.choices
fields
mapChanges:
OrderingFilter
andAutoOrderingFilter
Meta.order_by
andorder_by_field
.get_ordering_field
intoget_ordering_filter
. While now deprecated, the behavior forMeta.order_by
is completely backwards compatible with the caveat that it only works for theMeta.fields
list syntax.get_ordering_filter
that prevents undefined behavior from occurring when using theMeta.fields
dict syntax withMeta.order_by
.get_order_by
andget_ordering_field
.Notes:
get_order_by
andget_ordering_field
, assertions were chosen over deprecation warnings because those changes are forwards incompatible. The best that can be done is to warn the user that the behavior has changed. Otherwise, the behavior would silently change after upgrading, as those methods are no longer invoked.TODO:
strict
andorder_by_field
moves.Meta.order_by
deprecationget_order_by
,get_ordering_field
, etc...)test_filterset.FilterSetOrderingTests.test_ordering_when_unbound
)