Skip to content
Discussion options

You must be logged in to vote

Untested, but try something like this:

        query_params={
            'object_types': [ContentType.objects.get_for_model(Device).pk]
        },

or

        query_params={
            'object_types': [ContentType.objects.get(app_label='dcim', model='device').pk]
        },

I got this from the Netbox source code:

    def test_object_types(self):
        object_types = ContentType.objects.filter(model__in=['site', 'rack'])
        params = {'object_types': [object_types[0].pk, object_types[1].pk]}
        self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)

and

        object_types = (
            ContentType.objects.get(app_label='dcim', model='site'),
            Con…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@wz4
Comment options

@candlerb
Comment options

@wz4
Comment options

Answer selected by wz4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants