Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TreeAdmin displaying odd ordering with more than 1 root node #2

Copy link
Copy link
@kronok

Description

@kronok
Issue body actions

model

class Step(CTENode):
    description = models.CharField(max_length=75, null=True, blank=True)
    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, limit_choices_to=step_choices, null=True, blank=True)
    object_id = GfkLookupField('content_type', null=True, blank=True)
    content_object = GenericForeignKey('content_type', 'object_id')
    is_active = models.BooleanField(verbose_name="Active", default=True, help_text="If not active, subscribers will still be allowed to move to this step, but this step won't run until it's active. Consider this a good way to 'hold' subscribers on this step. Note: Step children won't run either.")
    position = models.PositiveIntegerField(db_index=True, editable=False, default=0)

    _cte_node_path = 'cte_path'
    _cte_node_order_by = ('position',)

admin

class StepAdmin(TreeAdmin):
    model = Step
    generic_raw_id_fields = ['content_object']
    raw_id_fields = ('parent',)
    list_display = ('indented_title', 'move_column')

issue

>>> root_one = Step.objects.create(description='root_one')
>>> root_one_middle = Step.objects.create(description='root_one_middle', parent=root_one)
>>> root_one_bottom = Step.objects.create(description='root_one_bottom', parent=root_one_middle)

root_one

That looks as expected. Let's add another root node.

>>> root_two = Step.objects.create(description='root_two')
>>> root_two_middle = Step.objects.create(description='root_two_middle', parent=root_two)
>>> root_two_bottom = Step.objects.create(description='root_two_bottom', parent=root_two_middle)

root_two
It only seems to look good with 1 root node. Everything gets displayed properly even when adding multiple children all over the place, but as soon as another root node gets in, it gets wonky. Only happens in Admin. Likely has something to do with TreeAdmin's get_ordering method, but I'm curious if you're able to re-create this with your Page model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.