Hi,
I am using Django Rest Framework Ember Data adapter. I have a user model for which I want to use “username” as its key. For example, I have:
// models/user.js:
export default DS.Model.extend({
username: DS.attr(),
first_name: DS.attr(),
last_name: DS.attr(),
email: DS.attr(),
is_active: DS.attr('boolean', { readOnly: true })
});
and
// serializers/user.js
export default DS.DjangoRESTSerializer.extend({
primaryKey: 'username'
});
Problem is, after I modify primaryKey as above, the {{id}} field in templates start showing the username, and {{username}} becomes empty.
Also I saw this in the DRF adapter code in updateRecord:
var id = get(record, 'id'); //todo find pk (not always id)
I guess primary key support is not there yet, and I should address the user model with its numeric ID not to confuse things.
The other problem I had is that I had to use readOnly on one of the fields as below, to generate a PATCH request instead of PUT:
is_active: DS.attr('boolean', { readOnly: true })
This triggers a PATCH request which DRF accepts as OK. Otherwise for a user model partial update adapter generates a PUT, which gets rejected.
Finally in DRF adapter there seems to be Async belongsTo/hasMany issue but issue seems to be closed. Is it still pending, or what is a good workaround? https://github.com/toranb/ember-data-django-rest-adapter/pull/63
Thanks, Bahadir