id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 18275 documentation: invalid foreign key and select_related adriannye@… nobody "Let's say Book has a foreign key to Author. If there is a invalid id in the Author field of any Book instance, then these two queries get a different set of Book instances: Book.objects.all() Book.objects.select_related('author').all() The second query will omit the Book objects that have an author field that points nowhere. This surprised me since I thought of select_related as only ADDING information to a query. In this situation it also REMOVES information. Invalid keys can happen with a database that does not have referential integrity checking like mysql with MyISAM." Uncategorized closed Documentation 1.3 Normal wontfix Unreviewed 0 0 0 0 1 0