Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objects.all() does not return all the data present in the collection #218

Open
rakeshramesh1989 opened this issue Jul 25, 2015 · 1 comment

Comments

@rakeshramesh1989
Copy link

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" : "[email protected]", "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" : "[email protected]", "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 .

@pons1991
Copy link

Are u able to solve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants