Creation of ConfigContexts via the API fails when related objects are assigned #1879

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

Originally created by @jeremystretch on GitHub (Jul 31, 2018).

Environment

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

Steps to Reproduce

  1. Attempt to create a new ConfigContext via a POST request to the API, with one or more sites (or other objects) assigned to it. For example:
curl -X POST \
-H "Authorization: Token <TOKEN>" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://localhost:8000/api/extras/config-contexts/ \
--data '{"sites":[6],"id":0,"name":"Test","weight":1000,"is_active":true,"data":{"foo":123}}'

Expected Behavior

A new ConfigContext should be created successfully.

Observed Behavior

An exception is raised:

The `.create()` method does not support writable nested fields by default.
Write an explicit `.create()` method for serializer `extras.api.serializers.ConfigContextSerializer`, or set `read_only=True` on nested serializer fields.
Originally created by @jeremystretch on GitHub (Jul 31, 2018). ### Environment * Python version: 3.5.2 * NetBox version: 2.4-beta1 ### Steps to Reproduce 1. Attempt to create a new ConfigContext via a POST request to the API, with one or more sites (or other objects) assigned to it. For example: ``` curl -X POST \ -H "Authorization: Token <TOKEN>" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ http://localhost:8000/api/extras/config-contexts/ \ --data '{"sites":[6],"id":0,"name":"Test","weight":1000,"is_active":true,"data":{"foo":123}}' ``` ### Expected Behavior A new ConfigContext should be created successfully. ### Observed Behavior An exception is raised: ``` The `.create()` method does not support writable nested fields by default. Write an explicit `.create()` method for serializer `extras.api.serializers.ConfigContextSerializer`, or set `read_only=True` on nested serializer fields. ```
adam closed this issue 2025-12-29 17:20:02 +01:00
Author
Owner

@prx-nvdm commented on GitHub (Aug 2, 2018):

The same thing happens when you try to update a config-context @jeremystretch

@prx-nvdm commented on GitHub (Aug 2, 2018): The same thing happens when you try to update a config-context @jeremystretch
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1879