Changes between Initial Version and Version 2 of Ticket #28035


Ignore:
Timestamp:
Apr 6, 2017, 1:03:53 PM (8 years ago)
Author:
Tim Graham
Comment:

I'm not sure if this is feasible to implement. How would it work?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28035

    • Property Summary Help Django Programmer to link a Query in their database logs with the Python line of codes that generated the request.Help Django Programmer to link a Query in their database logs with the Python lines of code that generated the request.
    • Property Component UncategorizedDatabase layer (models, ORM)
    • Property Type UncategorizedNew feature
  • Ticket #28035 – Description

    initial v2  
    88
    99Then you would be able to link easily where your request have been generated from in your python code.
    10 
    11     SELECT * FROM users WHERE id = 1; -- users/views.py L.21 `user = Users.objects.get(pk=request.user.id)`
    12 
     10{{{
     11SELECT * FROM users WHERE id = 1; -- users/views.py L.21 `user = Users.objects.get(pk=request.user.id)`
     12}}}
    1313It is especially useful when you create conditionals QuerySet:
    14 
    15     SELECT * FROM users WHERE name LIKE 'enac%' ORDER BY username; -- users/views.py L.18 `qs = Users.objects.all() \n users/views.py L.25 `qs = qs.filter(name__startswith="enac")` \n users/views.py L.30 `qs = qs.order_by('username')` \n templates/user_search.html L.55 `{% for user in users %}`
    16 
     14{{{
     15SELECT * FROM users WHERE name LIKE 'enac%' ORDER BY username; -- users/views.py L.18 `qs = Users.objects.all() \n users/views.py L.25 `qs = qs.filter(name__startswith="enac")` \n users/views.py L.30 `qs = qs.order_by('username')` \n templates/user_search.html L.55 `{% for user in users %}`
     16}}}
    1717If we want to do that as a library outside of Django, it means we would have to monkey patch the QuerySet object.
    1818Do we want to make it a Django Feature?
Back to Top