Comments (16)
I tried new Date().toJSON().slice(0, 10)
, and that works. Seems a reasonable workaround.
from ember-django-adapter.
It seems that the issue is that I am only storing a date
in the backend. The date is defined in my model as follows:
event_date = models.DateField(default=date.today)
If I replace this with
event_date = models.DateTimeField(default=datetime.now)
then everything works as expected. Nevertheless, I'd like it if the adapter/DRF could convert the JS Date
object to the appropriate day. However, I can imagine that this is simply beyond what the adapter can reasonably do. (How could it know that the API only wants a date?)
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.
from ember-django-adapter.
OK, I was too quick. It turns out that in the DateTimeField
case, the API does not return 400, but it does not record the date field at all. So my workaround doesn't work actually. Whether the back-end expects a DateField
or a DateTimeField
it doesn't quite work. In the first case the POST returns 400. In the second case it is 200, but is silently unsuccessful.
from ember-django-adapter.
The adapter should work with both DateField
and DateTimeField
without too much headache. I am looking into this.
from ember-django-adapter.
@ewilson this is still on my todo list. currently battling some dev issues with ember-cli and bower
from ember-django-adapter.
@dustinfarris No worries, its not a blocker for my toy project. I appreciate what you are doing.
from ember-django-adapter.
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).
Personally, I think this is a bug in DRF, or at least a deficiency. We will either need to open a PR with DRF (that may or may not get accepted), or add custom date
and datetime
transforms to the adapter library that can be imported as needed by EDA users.
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
from ember-django-adapter.
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
from ember-django-adapter.
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
from ember-django-adapter.
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
from ember-django-adapter.
What I'm passing inside the POST is the ISO-8601 standard representation of a Javascript date.
It's pretty strange that DRF is not parsing it correctly.
from ember-django-adapter.
Yeah, DRF will process that just fine for DateTimeField, but not for DateField.
from ember-django-adapter.
Is it a bug? Should we report it?
On Tue, Feb 10, 2015 at 7:10 PM, Dustin Farris [email protected]
wrote:
Yeah, DRF will process that just fine for DateTimeField, but not for
DateField.—
Reply to this email directly or view it on GitHub
#47 (comment)
.
Founder e CEO di SurveyLab
https://surveylab.me/Android Engineer @ musiXmatch
http://www.musixmatch.com/
Skype: e.ricci.designfuture
Twitter: @StErMi https://twitter.com/stermi
Linkedin: https://www.linkedin.com/in/emanuelericci
Google+: https://plus.google.com/u/0/+EmanueleRicci/posts
Hangout: [email protected]
from ember-django-adapter.
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.
from ember-django-adapter.
@ewilson thanks. That sounds like a candidate for a "date" transform.
from ember-django-adapter.
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 ?
from ember-django-adapter.
Related Issues (20)
- What are the advantages/disadvantages of using this package vs django-rest-framework-json-api? HOT 2
- Fastboot - Error: The adapter operation was aborted HOT 3
- upload file
- Why embedded record is not populated with Ember.Model? HOT 2
- An in-range update of loader.js is breaking the build 🚨 HOT 9
- An in-range update of ember-data is breaking the build 🚨 HOT 11
- An in-range update of ember-cli-htmlbars is breaking the build 🚨 HOT 1
- Correctly serialize lists of URLs for nested relationships HOT 3
- An in-range update of ember-disable-prototype-extensions is breaking the build 🚨 HOT 1
- An in-range update of ember-cli-inject-live-reload is breaking the build 🚨 HOT 1
- Upgrade ember-cli
- Dependecy problem with ember-inflector HOT 1
- Update to Ember-Data v3.0 HOT 21
- Acceptance test fails because CRUD operation didn't finish up before app shutdown HOT 4
- Generate adapter and serializer in pods
- CircleCI fails with pip install mkdocs HOT 11
- Easy to get multiple versions of ember-data HOT 1
- Website/Documentation 404 HOT 8
- Import AdapterError and InvalidError from "DS" object HOT 1
- No release with latest commits HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-django-adapter.