#19261: Page.__getitem__ usage causes queryset to evaluate when doing method lookups -------------------------------------+------------------------------------- Reporter: trbs | Owner: nobody Type: | Status: new Cleanup/optimization | Version: 1.4 Component: Template system | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: page, type_error, | Needs documentation: 0 __getitem__, pagination | Patch needs improvement: 0 Has patch: 1 | UI/UX: 0 Needs tests: 0 | Easy pickings: 1 | -------------------------------------+-------------------------------------
Comment (by trbs): Ah i see. I thought it was strange. I confused __getattribute__ which would be a lookup when accessing a member. Sorry my bad. So are you suggestion that the 'proper' fix would be that the template system should not do slicing operation when a function which the same exists on the object ? I guess that would break backwards compatibility... Putting the optimization in here is much easier for this specific case. (t.b.h. I think calling it a corner case does not really do the problem justice as the problem itself is not so much a corner case but applies any method on page_obj called from the template. But I agree that most people that would have problems with this query will most likely also have a problem with the COUNT() query coming out of pagination. At least on PostgreSQL) Last but not least :) I updated the patch... also slices should be honored in __getitem__. -- Ticket URL: <https://code.djangoproject.com/ticket/19261#comment:2> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.