AttributeError when creating a new object with tags assigned #1885

Closed
opened 2025-12-29 17:20:04 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Aug 2, 2018).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.4-beta1

Steps to Reproduce

Attempt to create a new site with the following API request:

curl -X POST \
-H "Authorization: Token <TOKEN>" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://localhost:8000/api/dcim/sites/ \
--data '{"name": "Test Site", "slug": "test-site", "tags": ["foo", "bar"]}'

Expected Behavior

The site should be created with the specified tags assigned to it.

Observed Behavior

Received an AttributeError exception:

...
  File "/home/jstretch/netbox/netbox/utilities/api.py", line 65, in to_internal_value
    content_type = ContentType.objects.get_for_model(obj)
  File "/home/jstretch/.virtualenvs/netbox/lib/python3.5/site-packages/django/contrib/contenttypes/models.py", line 40, in get_for_model
    opts = self._get_opts(model, for_concrete_model)
  File "/home/jstretch/.virtualenvs/netbox/lib/python3.5/site-packages/django/contrib/contenttypes/models.py", line 27, in _get_opts
    model = model._meta.concrete_model
AttributeError: 'NoneType' object has no attribute '_meta'
Originally created by @jeremystretch on GitHub (Aug 2, 2018). ### Environment * Python version: 3.5.2 * NetBox version: 2.4-beta1 ### Steps to Reproduce Attempt to create a new site with the following API request: ``` curl -X POST \ -H "Authorization: Token <TOKEN>" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ http://localhost:8000/api/dcim/sites/ \ --data '{"name": "Test Site", "slug": "test-site", "tags": ["foo", "bar"]}' ``` ### Expected Behavior The site should be created with the specified tags assigned to it. ### Observed Behavior Received an AttributeError exception: ``` ... File "/home/jstretch/netbox/netbox/utilities/api.py", line 65, in to_internal_value content_type = ContentType.objects.get_for_model(obj) File "/home/jstretch/.virtualenvs/netbox/lib/python3.5/site-packages/django/contrib/contenttypes/models.py", line 40, in get_for_model opts = self._get_opts(model, for_concrete_model) File "/home/jstretch/.virtualenvs/netbox/lib/python3.5/site-packages/django/contrib/contenttypes/models.py", line 27, in _get_opts model = model._meta.concrete_model AttributeError: 'NoneType' object has no attribute '_meta' ```
adam added the type: bugstatus: accepted labels 2025-12-29 17:20:04 +01:00
adam closed this issue 2025-12-29 17:20:04 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 3, 2018):

Fixed by #2297

@jeremystretch commented on GitHub (Aug 3, 2018): Fixed by #2297
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1885