jvanderaa / jvanderaa.github.io

GitHub Pages
3 stars 0 forks source link

Nautobot Tags #46

Open jvanderaa opened 1 year ago

jvanderaa commented 1 year ago

Anyone know how to assign content types to a tag directly in the object model? I've created a tag in a job using the Tag class, but I can't figure out how to assign content types. When I try to do it directly (content_types as an attribute of the tag) I get an error that I can't assign content types directly and that I should use content_types.set(). I've been messing around with mytag.content_types.set() but I can't figure out the proper parameters to use. I thought it would be mytag.content_types.set(['dcim.device']) but that throws an error: ValueError: Field 'id' expected a number but got 'dcim.device'.

https://github.com/nautobot/nautobot/blob/develop/nautobot/extras/tests/test_tags.py#L102-L105