In a current project, I am utilizing the Django auth backend, Django REST framework API, and Backbone.
var User = Backbone.Model.extend({
urlRoot: host + 'api/users/'
});
// django auth response
var isAuthenticated = {{ request.user.is_authenticated|yesno:"true,false" }};
if (isAuthenticated){
var userID = {{ request.user.id }}; // django user id
console.log(userID); // verifying value
var currentUser = new User({id: userID});
currentUser.fetch();
var username = currentUser.get('username');
console.log(currentUser); // verifying value
Result displayed in console.log(currentUser)
attributes: Object
email: "y****@*****m"
first_name: ""
id: 1
is_staff: true
last_name: ""
url: "http://127.0.0.1:8000/api/users/1/"
username: "yorsant"
How do you interpret the attributes:Object
?