-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
print SQL executed #71
Comments
As you can see from the code snippet above, DjangoQL returns normal Django querysets, so you can use the same techniques even after its search was applied, no need to modify the library code. Alternatively, you can take a look at common ways to debug Django queries, for example, Django Debug Toolbar is my favorite. |
Where is it returned to ? |
|
Where in my django admin get_search_results getting called ? is it overwrtite get_queryset ? |
in your from django.contrib import admin
from djangoql.admin import DjangoQLSearchMixin
from .models import Book
@admin.register(Book)
class BookAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
def get_search_results(self, *args, **kwargs):
qs, use_distinct = super().get_search_results(*args, **kwargs)
print(qs.query)
return qs, use_distinct |
Why I see "ORDER BY "instagram_data_follower"."id" DESC" on the sql statement ? |
Probably because you have |
BTW
otherwise it will fail on wrong syntex |
I found none ordering |
Well, it depends on your use case where it would be appropriate to apply it. I suppose at this point we're already discussing how Django works, and not how DjangoQL works. Is there anything else related to DjangoQL I could help you with? |
How can I apply a search from djangoQL using a something else: Filter, once I click on it I want it to execute a query via djangoql, I know how to modify it: instead ? Can I contribute $ to the project BTW ? |
Once you click on a filter option on the right, the page reloads itself. Upon page loading, Django takes the So if you manage to do a redirect to the same page with
Thanks for asking! We don't have donations configured yet, but if you check our commercial project - Teamplify, and provide some feedback for it, that would be awesome. |
I am looking for a way to handle the SQL executed in djangoql filters.
I can change apply_search but is there an official way ? same as I do explain on QS ?
This is working:
def apply_search(queryset, search, schema=None):
"""
Applies search written in DjangoQL mini-language to given queryset
"""
ast = DjangoQLParser().parse(search)
schema = schema or DjangoQLSchema
schema_instance = schema(queryset.model)
schema_instance.validate(ast)
qs = queryset.filter(build_filter(ast, schema_instance))
print('djangoql_sql: ', qs.query)
print('djangoql_explain: ', qs.explain())
return qs
The text was updated successfully, but these errors were encountered: