Interface sorting broken in Device view #857

Closed
opened 2025-12-29 16:26:23 +01:00 by adam · 2 comments
Owner

Originally created by @mweinelt on GitHub (Apr 11, 2017).

Issue type: Bug report

Python version: 3.6
NetBox version: 2.0-beta2

According to the Interface model the sorting for Interfaces is defined as follows:

class Interface(models.Model):
    class Meta:
        ordering = ['device', 'name']

The table is being rendered in a for loop in https://github.com/digitalocean/netbox/blob/v2.0-beta2/netbox/templates/dcim/device.html#L445-L453:

                 <table class="table table-hover panel-body">
                    {% for iface in interfaces %}
                        {% include 'dcim/inc/interface.html' with selectable=True %}
                    {% empty %}
                        <tr>
                            <td colspan="4">No interfaces defined</td>
                        </tr>
                    {% endfor %}
                </table>

However interfaces are currently not sorted by name:

Interface panel in device view

Originally created by @mweinelt on GitHub (Apr 11, 2017). ### Issue type: Bug report **Python version:** 3.6 **NetBox version:** 2.0-beta2 According to the Interface model the sorting for Interfaces is defined as follows: ```python class Interface(models.Model): class Meta: ordering = ['device', 'name'] ``` The table is being rendered in a for loop in https://github.com/digitalocean/netbox/blob/v2.0-beta2/netbox/templates/dcim/device.html#L445-L453: ```jinja <table class="table table-hover panel-body"> {% for iface in interfaces %} {% include 'dcim/inc/interface.html' with selectable=True %} {% empty %} <tr> <td colspan="4">No interfaces defined</td> </tr> {% endfor %} </table> ``` However interfaces are currently not sorted by name: ![Interface panel in device view](https://i.imgur.com/4SmzqJa.png)
adam closed this issue 2025-12-29 16:26:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 11, 2017):

Interfaces are ordered based on the ordering logic selected on the parent device type. Currently the interfaces are being ordered by numeric position (0, 1, 2). If you switch the device type's ordering to "name" the interfaces should appear as you want.

@jeremystretch commented on GitHub (Apr 11, 2017): Interfaces are ordered based on the ordering logic selected on the parent device type. Currently the interfaces are being ordered by numeric position (0, 1, 2). If you switch the device type's ordering to "name" the interfaces should appear as you want.
Author
Owner

@mweinelt commented on GitHub (Apr 11, 2017):

Oh yeah, that was it. Thanks for the prompt explanation.

@mweinelt commented on GitHub (Apr 11, 2017): Oh yeah, that was it. Thanks for the prompt explanation.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#857