Opened 14 years ago
Closed 14 years ago
#15979 closed Bug (duplicate)
backwards related query set of a model object, not yet saved, returns ALL db objects instead of an empty list.
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Following relationships "backward"
Example:
b = Blog.objects.get(id=1)
b.entry_set.all() # Returns all Entry objects related to Blog.
So far so good.
But notice something quite scary here. If you do:
newblog = Blog(name='my-new-blog', tag_line='testing') # this is a new Blog obj that has not been saved yet.
newblog.entry_set.all() # This will return ALL Entry objects in db, instead of an empty list, or just exception.
I think the returned value should be an empty list.
Duplicate of #15146 and possibly #14615