Skip to content
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

Rack group filter on devices #270

Closed
bellwood opened this issue Jul 12, 2016 · 1 comment
Closed

Rack group filter on devices #270

bellwood opened this issue Jul 12, 2016 · 1 comment
Labels
type: feature Introduction of new functionality to the application

Comments

@bellwood
Copy link
Contributor

This would be extremely helpful.

@jeremystretch jeremystretch added the type: feature Introduction of new functionality to the application label Jul 12, 2016
@bellwood
Copy link
Contributor Author

bellwood commented Jul 13, 2016

Just some notes:

Per our irc conversation:

presumably I also have to update /dcim/filters.py "class DeviceFilter" too correct to enable the actual filtering? 

i tried added the two "django_filters.ModelMultipleChoiceFilter" for group and group_id but it errors and debug tells me i have a field error, the rack group bits arent available fields

none of the choices relate to rack group

Specific changes to /dcim/filters.py:

Add:

    group_id = django_filters.ModelMultipleChoiceFilter(
        name='group',
        queryset=RackGroup.objects.all(),
        label='Group (ID)',
    )
    group = django_filters.ModelMultipleChoiceFilter(
        name='group',
        queryset=RackGroup.objects.all(),
        to_field_name='slug',
        label='Group',
    )

To...
class DeviceFilter(django_filters.FilterSet):

...at line 190 and then edit class meta to include those:

    class Meta:
        model = Device
        fields = ['q', 'name', 'site_id', 'site', 'rack_id', 'role_id', 'role', 'device_type_id', 'manufacturer_id',
                  'manufacturer', 'model', 'platform_id', 'platform', 'status', 'is_console_server', 'is_pdu',
                  'is_network_device', 'group_id', 'group']

The debug error is:

FieldError at /dcim/devices/
Cannot resolve keyword 'group' into field. Choices are: comments, console_ports, created, cs_ports, device_bays, device_role, device_role_id, device_type, device_type_id, face, id, interfaces, last_updated, modules, name, parent_bay, platform, platform_id, position, power_outlets, power_ports, primary_ip4, primary_ip4_id, primary_ip6, primary_ip6_id, rack, rack_id, secrets, serial, status

if-fi pushed a commit to if-fi/netbox that referenced this issue Oct 1, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants