#34819: GenericForeignKey.get_prefetch_queryset()
--------------------------------------+------------------------------------
     Reporter:  Richard Laager        |                    Owner:  nobody
         Type:  Bug                   |                   Status:  new
    Component:  contrib.contenttypes  |                  Version:  3.2
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Richard Laager):

 That's an interesting point. That's the opposite of the scenario I care
 about. My scenario is real world, and IMHO reasonable.

 > I believe one should not use a custom field for object_id referring a
 foreign key.

 I agree. I don't think it is reasonable to be messing with an object_id
 for a GenericForeignKey. That's supposed to be a plain old string so that
 it can represent primary keys of other objects.

 > Maybe a warning in docs would suffice?

 For that part of it, yes.

 So I think a reasonable fix here is:
 1. The patch I've provided.
 2. A test case. That can be similar to your test case, except that
 CustomCharField() should be used on the object pointed to by the
 GenericForeignKey: i.e. the Foo object, not the Bar object.
 3. A doc warning that the object_id for a GenericForeignKey() should be an
 ordinary CharField or the same field type as the primary key of the
 objects it will point to.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34819#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018b846e82d3-1c7371b5-d1be-4727-b76c-a7da3a31ef0a-000000%40eu-central-1.amazonses.com.

Reply via email to