Skip to content
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

Filtered Query Set #221

Open
snoba opened this issue Jan 19, 2019 · 1 comment
Open

Filtered Query Set #221

snoba opened this issue Jan 19, 2019 · 1 comment

Comments

@snoba
Copy link

snoba commented Jan 19, 2019

I have a scenario that I need to retrieve records from a model, that satisfy certain conditions.
For example, the request could be described as:
"SELECT * FROM model WHERE column_1='value_1' AND column_2='value_2'
How could I implement this? Actually, I saw the examples, but I don't have an efficient idea to do this.
Would you please help me in View definition or refer to proper sample?

@snoba
Copy link
Author

snoba commented Jan 20, 2019

I found a solution. It seems that we should implement a get_queryset(self) method to apply targeted filters:

    def get_queryset(self):
        return Entity.objects.filter('item_1'='value_1')

While this could results in proper table values, but, the performance of loading decreases significantly.
Is there any idea on having filtering without performance issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant