home / django_tickets / tickets

tickets: 7823

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
7823 2008-07-19 00:50:16 2011-09-28 16:12:17 2022-03-06 03:40:38.786824 Accepted closed Database layer (models, ORM)     dev fixed ForeignKey get_db_prep_lookup doesn't work for custom primary key If a parent model has a user-defined field as a primary key: {{{ class Parent(models.Model): user_id = CutomUserField(primary_key=True) class Child(models.Model): parent = models.ForeignKey(Parent) }}} then this query will fail: {{{ p = Parent(...) Child.objects.filter(parent=p) }}} This happens because get_db_prep_lookup doesn't get called on p.user_id and its value (which is a custom user class) gets passed as an sql parameter into db. Patch follows. P.S. A bug is very practical: we have custom non-model user objects instead of contrib.auth.models.User and can't reference them from models with custom UserField because many queries using those models would break. mtredinnick isagalaev   0 1 0 0 0 0
Powered by Datasette · Queries took 35.432ms