Fixing incomplete filtersets #1990
gsnider2195
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Fixing incomplete filtersets in nautobot core
Documentation on filter best practices
nautobot development best practices
Identifying missing filters
Add this test to
nautobot.utilities.testing.filters.FilterTestCases.FilterTestCase
Run filter unit tests for your app
For dcim:
inv unittest -k -l nautobot.dcim.tests.test_filters
Filter to field type mapping
nautobot.utilities.BaseFilterSet
Filter names
power_feeds
notpowerfeeds
dcim.FrontPortTemplate
has a ForeignKey relationship todcim.RearPortTemplate
namedrear_port
. The corresponding filter should be more accurately namedrear_port_template
, and in a future major Nautobot release we might consider renaming the foreign key as well.Relationship filters
Relationship filters should be named singular or plural based on the relationship type.
device.primary_ip4
,device.site
custom_field.content_types
,device.interfaces
MPTTModel
(except self referencing relationships)TreeNodeMultipleChoiceFilter
(which beginning in 1.4 will inherit fromNaturalKeyOrPKMultipleChoiceFilter
)NaturalKeyOrPKMultipleChoiceFilter
django_filters.ModelMultipleChoiceFilter
should only be used for objects that don't have a suitable key (name
orslug
) forNaturalKeyOrPKMultipleChoiceFilter
Many-to
relationships should have an additionalRelatedMembershipBooleanFilter
namedhas_{{ related object }}
interfaces
(NaturalKeyOrPKMultipleChoiceFilter
) andhas_interfaces
(RelatedMembershipBooleanFilter
)Beta Was this translation helpful? Give feedback.
All reactions