How to get all objects in a Django model(Databse table) based on a filter using AngularJs
<p>Hi I have a Django model as below:</p>

<pre><code>from __future__ import unicode_literals

from django.db import models
from django.contrib.auth.models import User
# Create your models here.

class Journal(models.Model):
    name = models.CharField(max_length=120)
    created_by = models.ForeignKey(User, related_name='+')
    date_created = models.DateTimeField(auto_now=False, auto_now_add=True)
    date_modified = models.DateTimeField(auto_now=True, auto_now_add=False )

    def __unicode__(self):
        return (self.name)
</code></pre>

<p>And my angularJs below:</p>

<pre><code>var app = angular.module("journalApp", []);
    app.controller("myCtrl", function($scope) {

});
</code></pre>

<p>How can I make a query in AngularJs so that i get all the objects from my Django model based on the user who logged in? Any idea guys? Thanks in advance.</p>

<p>To retrieve all Journal objects, you can create a view with <a href="http://www.django-rest-framework.org/" rel="nofollow">django REST framework</a> and on angular side simply create a <code>Service</code> and use <a href="https://docs.angularjs.org/api/ngResource/service/$resource" rel="nofollow"><code>$resource</code></a> or <a href="https://docs.angularjs.org/api/ng/service/$http" rel="nofollow"><code>$http</code></a> or go for recommended <a href="https://github.com/mgonto/restangular" rel="nofollow"><code>restangular</code></a> to retrieve the data from django rest api. <a href="http://www.django-rest-framework.org/" rel="nofollow">django REST framework</a> can also be used for authentication.</p>

python angularjs django