New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for reverse field ordering #108

Open
dspacejs opened this Issue May 24, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@dspacejs

dspacejs commented May 24, 2018

When using reverse ordering for a date field (such as -created_at) the following error is thrown:

AttributeError: 'Thread' object has no attribute '-created_at'

You can use reverse ordering like this using Django's Meta.ordering. But with Treebeard it doesn't work.

Here's my code as an example:

class Thread(MP_Node):
    node_order_by = ['-created_at']

    user = models.ForeignKey('User', on_delete=models.PROTECT, db_index=True)
    message = models.CharField(max_length=200)
    created_at = models.DateTimeField(default=timezone.now)

Is there a way to do this with Treebeard? My nodes need to be ordered by most recent.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment