Answer the question
In order to leave comments, you need to log in
How to make DRF and Ember.JS friends?
I want to know in detail how to work with this bundle.
1. How to output data to Ember from DRF? What steps need to be taken?
Registered router:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('products', { path: 'products' });
this.route('product', {path: 'product/:product_id'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model: function () {
return this.store.find('product');
}
});
import DS from 'ember-data';
export default DS.Model.extend({
scu: DS.attr(),
full_title: DS.attr(),
price: DS.attr()
});
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
host: 'http://127.0.0.1:8000',
namespace: 'api'
});
api/products
, it returns JSON like:[
{
"id": 1,
"scu": "191625",
"title": "hp ProBook 450 G2",
"price": "53598.00",
"url": "http://127.0.0.1:8000/api/products/1/",
"category": "Ноутбуки",
"images": [
{
"id": 1,
"image": "http://127.0.0.1:8000/media/catalog/product/images/191625/01.jpg"
}
]
},
...
]
settings.py
CORS_ORIGIN_ALLOW_ALL = True
. As I understand it, there will be no such problem in the deployment? And what security issues does this entail? Answer the question
In order to leave comments, you need to log in
I didn’t prepare such a bundle myself, but try to twist the project django-rest-framework-json-api project
There was recently a question about the django rest framework, and working with the adapter. Look at the Ember.js tag
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question