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 13137 GenericForeignKey does not allow content type PK 0 Justin de Vesine woodlee "The GenericForeignKey system does not properly recognize when a ContentType ID 0 is linked to. In django/contrib/contenttypes/generic.py, two specific instances are checking for ""if primarykey:"" rather than ""if primarykey is not None:"". This specifically came up in our environment because we are matching the ContentType ids to our legacy database content type ids, which start at 0 rather than 1. To reproduce, rename attached foobar_models.py to models.py and place in an app named 'foobar', then follow the directions in comments at the bottom of the models file. The attached proposed patch changes these two if statements to ""is not None"", which I believe is more correctly in the spirit of the code as well as allowing this functional case." Bug closed contrib.contenttypes dev Normal fixed contenttype genericforeignkey Accepted 1 0 0 0 0 0