#34249: Custom RelatedManager documentation should have side tip on
prefetch_related
-------------------------------------+-------------------------------------
               Reporter:  Vaughn     |          Owner:  nobody
  Koch                               |
                   Type:             |         Status:  new
  Cleanup/optimization               |
              Component:             |        Version:  4.1
  Documentation                      |       Keywords:  documentation
               Severity:  Normal     |  relatedmanager custom
           Triage Stage:             |  prefetch_related
  Unreviewed                         |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 This Django documentation shows how to use a custom manager for reverse
 relations.

 https://docs.djangoproject.com/en/4.1/topics/db/queries/#using-custom-
 reverse-manager

 In the given example, this works well as-is, but if you prefetch_related
 the entries when you're querying Blog, Django will use the
 prefetch_related cache and ignore the custom manager.

 This behavior may/may not be desired, but the documentation could use a
 side tip about this condition, maybe in a 'Good to know' infobox.

 Also, separately: one flaw in the documented approach is that you have to
 explicitly use the custom manager when making a query - there doesn't seem
 to be a way to make the custom manager the default, which can cause issues
 if you forget to add it to all your calls.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34249>
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/010701859cda23a1-c334b1a6-730f-4187-a7c6-8832721b984b-000000%40eu-central-1.amazonses.com.

Reply via email to