PUTs to Site Endpoint Requires Value for time_zone #1768

Closed
opened 2025-12-29 17:18:57 +01:00 by adam · 4 comments
Owner

Originally created by @zachmoody on GitHub (Jun 5, 2018).

Issue type

[ ] Feature request
[X] Bug report
[ ] Documentation

Environment

  • Python version: 2.6.7
  • NetBox version: 2.4-dev, but includes previous versions as well.

Description

More details over at digitalocean/pynetbox#59, but when the time_zone field is present and null we get an error saying it can't be null. Omitting the field doesn't return an error.

Originally created by @zachmoody on GitHub (Jun 5, 2018). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. For assistance with installation issues, or for any other issues other than those listed below, please raise your topic for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. Due to an excessive backlog of feature requests, we are not currently accepting any proposals which extend NetBox's feature scope. Do not prepend any sort of tag to your issue's title. An administrator will review your issue and assign labels as appropriate. ---> ### Issue type [ ] Feature request <!-- An enhancement of existing functionality --> [X] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) If you are submitting a bug report and have made any changes to the code base, please first validate that your bug can be recreated while running an official release. --> ### Environment * Python version: 2.6.7 * NetBox version: 2.4-dev, but includes previous versions as well. <!-- BUG REPORTS must include: * A list of the steps needed for someone else to reproduce the bug * A description of the expected and observed behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description More details over at digitalocean/pynetbox#59, but when the `time_zone` field is present and null we get an error saying it can't be null. Omitting the field doesn't return an error.
adam closed this issue 2025-12-29 17:18:58 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jun 6, 2018):

I know we talked about this offline, but looking at it again I think it's a question of semantics. The time zone is stored as a string, e.g. America/New_York. Thus, a null value isn't technically valid; an empty value would be represented as an empty string instead. The same error is returned for other CharFields when a null value is passed:

{
    "facility": [
        "This field may not be null."
    ]
}
@jeremystretch commented on GitHub (Jun 6, 2018): I know we talked about this offline, but looking at it again I think it's a question of semantics. The time zone is stored as a string, e.g. `America/New_York`. Thus, a null value isn't technically valid; an empty value would be represented as an empty string instead. The same error is returned for other CharFields when a null value is passed: ``` { "facility": [ "This field may not be null." ] } ```
Author
Owner

@zachmoody commented on GitHub (Jun 6, 2018):

Empty string works too. The only thing causing pynetbox to go sideways is that GET returns a null. So if the field goes unchanged by the user, it simply gets added as-is to the PUT.

@zachmoody commented on GitHub (Jun 6, 2018): Empty string works too. The only thing causing pynetbox to go sideways is that GET returns a `null`. So if the field goes unchanged by the user, it simply gets added as-is to the PUT.
Author
Owner

@jeremystretch commented on GitHub (Jun 6, 2018):

The documentation for django-timezone-field states that None should be a valid value for both input and output, so let's stick with your approach.

@jeremystretch commented on GitHub (Jun 6, 2018): The documentation for [`django-timezone-field`](https://github.com/mfogel/django-timezone-field/blob/master/timezone_field/fields.py) states that None should be a valid value for both input and output, so let's stick with your approach.
Author
Owner

@nue-melexis commented on GitHub (Nov 28, 2018):

Hi,

I still get this issue with version 2.4.3.
Check master commits https://github.com/digitalocean/netbox/commits/master?after=8d4329197a916ed5704ce774a77ec1f59c8a6328+279

Browsing files:
Still OK:
Post-release version bump @jeremystretch committed on Jul 2

NOK:
Closes #2211: Removed Python 2 instructions from the installation docs @jeremystretch committed on Jul 2

@jeremystretch
Can you hint me? (This history for the file at that 2 revisions deviates from March 1st)

Best Regards,
Norman

@nue-melexis commented on GitHub (Nov 28, 2018): Hi, I still get this issue with version 2.4.3. Check master commits https://github.com/digitalocean/netbox/commits/master?after=8d4329197a916ed5704ce774a77ec1f59c8a6328+279 Browsing files: Still OK: [Post-release version bump @jeremystretch committed on Jul 2](https://github.com/digitalocean/netbox/blob/302c14186a2020fa2a241cb0b0bbe1fd9dc0a367/netbox/dcim/api/serializers.py) NOK: [Closes #2211: Removed Python 2 instructions from the installation docs @jeremystretch committed on Jul 2 ](https://github.com/digitalocean/netbox/blob/104bd1b45f6a6f3b5d94fef4126c3b49413b33a3/netbox/dcim/api/serializers.py) @jeremystretch Can you hint me? (This history for the file at that 2 revisions deviates from March 1st) Best Regards, Norman
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1768