Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

order_by property #22

Merged
merged 1 commit into from
Oct 20, 2015
Merged

Conversation

tpeaton
Copy link
Contributor

@tpeaton tpeaton commented Oct 7, 2015

This adds an 'order_by' property that can be overriden to specify a custom ordering for tags. The default is ['id'].

Example:

class SortedTagSerializer(TagListSerializerField):
    order_by = ['name']


class SomeSerializer(TaggitSerializer, ModelSerializer):
    tags = SortedTagSerializer()

I haven't been able to get the tests to run locally yet as outlined in the docs. (But it looks like they worked fine on Travis)

@tpeaton tpeaton mentioned this pull request Oct 7, 2015
@glemmaPaul
Copy link
Owner

Thanks for the PR @tpeaton, I would love to add this option, but I don't think a default to id is a good idea. This may be because people already order on something else. What do you think?

@tpeaton
Copy link
Contributor Author

tpeaton commented Oct 19, 2015

Yea, I have mixed feelings about it as well. I was trying to avoid it, but it probably makes more sense to do an if block and only apply the ordering if order_by is specified. If you agree, I'll push up that change.

@glemmaPaul
Copy link
Owner

@tpeaton That sounds like a good idea yes! Could you (not necessarily needed) rebase the PR to one commit too?

@tpeaton
Copy link
Contributor Author

tpeaton commented Oct 19, 2015

Sure thing, thanks.

@glemmaPaul
Copy link
Owner

Merging this in, will be in the next release! Thanks for the great contribution! 👍

glemmaPaul added a commit that referenced this pull request Oct 20, 2015
@glemmaPaul glemmaPaul merged commit 6484d0f into glemmaPaul:master Oct 20, 2015
@tpeaton
Copy link
Contributor Author

tpeaton commented Oct 20, 2015

Awesome, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants