-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format of date_time custom fields through the REST API on GET are not compatible with POST #13925
Comments
Unfortunately this is a limitation of the We'll need to come up with a way to support multiple conforming date/time formats. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide. |
It seems the root issue is that Django REST Framework has taken it upon itself, for reasons unknown to me, to arbitrarily replace the We can work around this for custom fields for now by replacing the |
NetBox version
v3.5.4
Python version
3.10
Steps to Reproduce
Expected Behavior
The input format of datetime should be compatible with the output format.
Observed Behavior
We receive this error:
Correct me if I'm wrong, but the values observed through the API are serialized with django rest_framework, which could explain why there's a different format between the rest api and inside the database. But when we do a post, the validation go through extras/models/customfields.py and use
datetime.fromisoformat()
(also for deserialisation).Starting python 3.11 fromisoformat() is compatible with the YYYY-mm-ddTHH:MM:SSZ format, but not former version (see changed in version 3.11 in the doc). But it's not always easy to upgrade python.
I patched my version with
dateutil.parser.parse()
instead ofdatetime.fromisoformat()
and it's working as expected. Should I make a PR?Thanks
The text was updated successfully, but these errors were encountered: