type object 'X' has no attribute 'objects'
<p>I am using Django and Django Rest Framework 2.4.0</p>

<p>I get the Attribute error <code>type object 'Notification' has no attribute 'objects'</code></p>

<p><strong>models.py</strong></p>

<pre><code>class Notification(models.Model):
    NOTIFICATION_ID = models.AutoField(primary_key=True)
    user = models.ForeignKey(User, related_name='user_notification')
    type = models.ForeignKey(NotificationType)
    join_code = models.CharField(max_length=10, blank=True)
    requested_userid = models.CharField(max_length=25, blank=True)
    datetime_of_notification = models.DateTimeField()
    is_active = models.BooleanField(default=True)
</code></pre>

<p><strong>serializers.py:</strong></p>

<pre><code>class NotificationSerializer(serializers.ModelSerializer):
    class Meta:
        model = Notification
        fields = (
            'type',
            'join_code',
            'requested_userid',
            'datetime_of_notification'
        )
</code></pre>

<p><strong>api.py:</strong></p>

<pre><code>class Notification(generics.ListAPIView):
    serializer_class = NotificationSerializer
    def get_queryset(self):
        notifications = Notification.objects.all()
        return notifications
</code></pre>

<p>Can anybody help me to figure this out? It fails in <code>api.py</code> at the line <code>notifications = Notification.objects.all()</code></p>