-
Notifications
You must be signed in to change notification settings - Fork 49
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
posting date Date has wrong format. Use one of these formats instead: YYYY[-MM[-DD]] #47
Comments
It seems that the issue is that I am only storing a
If I replace this with
then everything works as expected. Nevertheless, I'd like it if the adapter/DRF could convert the JS Having thought it through, my guess is that there is no way for the adapter to solve my problem. Feel free to close. Comments are welcome. |
OK, I was too quick. It turns out that in the |
The adapter should work with both |
@ewilson this is still on my todo list. currently battling some dev issues with ember-cli and bower |
@dustinfarris No worries, its not a blocker for my toy project. I appreciate what you are doing. |
I've confirmed this bug. Basically, Ember has one notion of datetime, whereas Django has date and datetime. Ember Data's DateTransform sends a full ISO-8601 datetime value for everything, and DRF blows up if the model's field is a DateField (as opposed to a DateTimeField).
I'm open to opinions on which way is best, but I'm thinking the custom transforms would be nice quick fix for now. /cc @benkonrath |
It looks like the folks over at DRF already gave this some thought: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/fields.py#L920-L922 |
Hi I'm using AngularJS and AngularJS Bootstrap UI and the date returned by the JS datepicker is failing with the same error. On Django the model field is date_of_birth = models.DateField(null=True, blank=True) and when I pass it via POST the date is like this u'1987-09-03T00:00:00.000Z' but the serializer.is_valid() return that error |
Hi @StErMi, I'm not sure if it's possible to override that in Angular, but as a workaround you can tell DRF to accept a different format. http://www.django-rest-framework.org/api-guide/settings/#date-and-time-formatting |
What I'm passing inside the POST is the ISO-8601 standard representation of a Javascript date. |
Yeah, DRF will process that just fine for DateTimeField, but not for DateField. |
Is it a bug? Should we report it? On Tue, Feb 10, 2015 at 7:10 PM, Dustin Farris notifications@github.com
Founder e CEO di SurveyLab Skype: e.ricci.designfuture |
No, it's a design decision. See the link I posted—DRF is explicit about the formats that are accepted, but you can change them in your settings if you need to. |
I tried |
@ewilson thanks. That sounds like a candidate for a "date" transform. |
Hello im use reactjs for front-end and django rest framework for back-end and i want react just send date to backend but i dont know how can i do that ? and my datepicker jost input date but react send datetime for backend. any solution ? |
When I save a model that has a JS date (created with
new Date()
) I get the error:The date in the post was
2015-01-05T22:08:37.838Z
. So is this:Appreciate any help.
Using:
ember-cli 0.1.5
ember-data 1.0.0-beta.12
ember-django-adapter 0.5
django 1.7.1
djangorestframework 3.0.2
Python 3.4
The text was updated successfully, but these errors were encountered: