Background - I updated my data modes to include EmbeddedModelField .Once updated all the old data is not returned by object.all() function .Here goes my model
class Post(models.Model):
created_on = models.DateTimeField(auto_now_add=True, null=True)
title = models.CharField(max_length=300)
text = models.TextField()
tags = ListField()
comments = ListField(EmbeddedModelField('Comment'),null=True)
testing = models.TextField()
class Comment(models.Model):
created_on = models.DateTimeField(auto_now_add=True,null=True)
author = EmbeddedModelField('Author')
text = models.TextField()
class Author(models.Model):
author_name=models.CharField(max_length=255)
author_email=models.EmailField()
Background - I updated my data modes to include EmbeddedModelField .Once updated all the old data is not returned by object.all() function .Here goes my model
class Post(models.Model): created_on = models.DateTimeField(auto_now_add=True, null=True) title = models.CharField(max_length=300) text = models.TextField() tags = ListField() comments = ListField(EmbeddedModelField('Comment'),null=True) testing = models.TextField()
class Comment(models.Model): created_on = models.DateTimeField(auto_now_add=True,null=True) author = EmbeddedModelField('Author') text = models.TextField()
class Author(models.Model): author_name=models.CharField(max_length=255) author_email=models.EmailField()
Actual data present in the database
{ "offset" : 0, "rows": [ { "_id" : { "$oid" : "55b252b94a838a53d1dd89b5" }, "tags" : [], "text" : "", "title" : "I Like Cake", "comments" : [ { "text" : "The cake is a lie", "created_on" : { "$date" : "2015-07-25T03:47:07.664+0800" }, "id" : { "$oid" : "55b24feb4a838a52870ec9aa" }, "author" : { "author_email" : "bob@example.org", "author_name" : "Bob" } } ], "created_on" : { "$date" : "2015-07-24T22:59:05.850+0800" } } , { "_id" : { "$oid" : "55b359c54a838a70325056fb" }, "text" : "", "created_on" : { "$date" : "2015-07-25T17:41:25.697+0800" }, "tags" : [], "title" : "dddd" } , { "_id" : { "$oid" : "55b35a7b4a838a70325056fc" }, "text" : "Just wanted to drop a note from Django. Cya!", "created_on" : { "$date" : "2015-07-25T17:44:27.904+0800" }, "tags" : [ "mongodb", "django" ], "title" : "Hello MongoDB!" } , { "_id" : { "$oid" : "55b35be44a838a70a6d89fc9" }, "tags" : [ "mongodb", "django" ], "text" : "Just wanted to drop a note from Django. Cya!", "title" : "Hello modified data schema !", "comments" : [ "Great post!", "Please, do more of these!" ] } , { "_id" : { "$oid" : "55b35cdb4a838a70a6d89fca" }, "text" : "Just wanted to drop a note from Django. Cya!", "tags" : [ "mongodb", "django" ], "comments" : [], "title" : "Hello modified data schema !" } , { "_id" : { "$oid" : "55b35d6d4a838a7115bca0ab" }, "text" : "Just wanted to drop a note from Django. Cya!", "comments" : [], "tags" : [ "mongodb", "django" ] } , { "_id" : { "$oid" : "55b35d984a838a7115bca0ac" }, "text" : "no title", "comments" : [], "tags" : [ "mongodb", "django" ] } , { "_id" : { "$oid" : "55b3628d4a838a718bcd6c01" }, "tags" : [], "text" : "", "title" : "I like cake", "comments" : [ { "text" : "The cake is a lie", "created_on" : { "$date" : "2015-07-25T23:04:47.768+0800" }, "id" : { "$oid" : "55b35f3f4a838a718bcd6c00" }, "author" : { "author_email" : "test@example.org", "author_name" : "test" } } ], "created_on" : { "$date" : "2015-07-25T18:18:53.907+0800" } } ],
"total_rows" : 8 , "query" : {} , "millis" : 0 }
when I tired printing the objects on the python shell using the command
Post.objects.all() contains only 3 objects
whereas Post.objects.count() returns 8 .