How can i add filter to all querysets at the end of sql-query?












3















If i add filter in the manager, sql query to the database will be too long, because my filter will be at start of sql-query.



I need to run this filter at the end, after all the other filters and changes have been applied.



Current queryset:



links = Link.objects.all().filter_deleted()
links = links.filter(linkname='linkname', left_uuid__in=all_uuids)
links = links.filter(left_type='type')
links = links.values_list('left_uuid', 'right_uuid', 'right_type')


SQL query after compiling the queruset:



SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
FROM "baseobj_link"
WHERE (
"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
) AND
"baseobj_link"."is_deleted" = false AND
"baseobj_link"."linkname" = 'linkname' AND
"baseobj_link"."left_uuid" IN (
SELECT V0."uuid" AS Col1
FROM "structure_cgw" V0
WHERE (
V0."id" IN (
SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
FROM "structure_cgw" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
) AND
V0."is_deleted" = false
)
) AND
"baseobj_link"."left_type_id" = 6
);
args=(2848, False, 'linkname', 2848, False, 6)


The part that is generated by filter_deleted():



"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
)


It's necessary to add this code at the end of the all queries for this model, so it's not a simple task.



How can this be solved most efficiently?










share|improve this question




















  • 1





    Hello, please elaborate your question and add some code of what you are trying to achieve

    – Walucas
    Nov 26 '18 at 13:47
















3















If i add filter in the manager, sql query to the database will be too long, because my filter will be at start of sql-query.



I need to run this filter at the end, after all the other filters and changes have been applied.



Current queryset:



links = Link.objects.all().filter_deleted()
links = links.filter(linkname='linkname', left_uuid__in=all_uuids)
links = links.filter(left_type='type')
links = links.values_list('left_uuid', 'right_uuid', 'right_type')


SQL query after compiling the queruset:



SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
FROM "baseobj_link"
WHERE (
"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
) AND
"baseobj_link"."is_deleted" = false AND
"baseobj_link"."linkname" = 'linkname' AND
"baseobj_link"."left_uuid" IN (
SELECT V0."uuid" AS Col1
FROM "structure_cgw" V0
WHERE (
V0."id" IN (
SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
FROM "structure_cgw" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
) AND
V0."is_deleted" = false
)
) AND
"baseobj_link"."left_type_id" = 6
);
args=(2848, False, 'linkname', 2848, False, 6)


The part that is generated by filter_deleted():



"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
)


It's necessary to add this code at the end of the all queries for this model, so it's not a simple task.



How can this be solved most efficiently?










share|improve this question




















  • 1





    Hello, please elaborate your question and add some code of what you are trying to achieve

    – Walucas
    Nov 26 '18 at 13:47














3












3








3


0






If i add filter in the manager, sql query to the database will be too long, because my filter will be at start of sql-query.



I need to run this filter at the end, after all the other filters and changes have been applied.



Current queryset:



links = Link.objects.all().filter_deleted()
links = links.filter(linkname='linkname', left_uuid__in=all_uuids)
links = links.filter(left_type='type')
links = links.values_list('left_uuid', 'right_uuid', 'right_type')


SQL query after compiling the queruset:



SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
FROM "baseobj_link"
WHERE (
"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
) AND
"baseobj_link"."is_deleted" = false AND
"baseobj_link"."linkname" = 'linkname' AND
"baseobj_link"."left_uuid" IN (
SELECT V0."uuid" AS Col1
FROM "structure_cgw" V0
WHERE (
V0."id" IN (
SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
FROM "structure_cgw" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
) AND
V0."is_deleted" = false
)
) AND
"baseobj_link"."left_type_id" = 6
);
args=(2848, False, 'linkname', 2848, False, 6)


The part that is generated by filter_deleted():



"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
)


It's necessary to add this code at the end of the all queries for this model, so it's not a simple task.



How can this be solved most efficiently?










share|improve this question
















If i add filter in the manager, sql query to the database will be too long, because my filter will be at start of sql-query.



I need to run this filter at the end, after all the other filters and changes have been applied.



Current queryset:



links = Link.objects.all().filter_deleted()
links = links.filter(linkname='linkname', left_uuid__in=all_uuids)
links = links.filter(left_type='type')
links = links.values_list('left_uuid', 'right_uuid', 'right_type')


SQL query after compiling the queruset:



SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
FROM "baseobj_link"
WHERE (
"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
) AND
"baseobj_link"."is_deleted" = false AND
"baseobj_link"."linkname" = 'linkname' AND
"baseobj_link"."left_uuid" IN (
SELECT V0."uuid" AS Col1
FROM "structure_cgw" V0
WHERE (
V0."id" IN (
SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
FROM "structure_cgw" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
) AND
V0."is_deleted" = false
)
) AND
"baseobj_link"."left_type_id" = 6
);
args=(2848, False, 'linkname', 2848, False, 6)


The part that is generated by filter_deleted():



"baseobj_link"."id" IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
)


It's necessary to add this code at the end of the all queries for this model, so it's not a simple task.



How can this be solved most efficiently?







django database orm django-queryset






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 14:46







Sergey

















asked Nov 26 '18 at 13:45









SergeySergey

164




164








  • 1





    Hello, please elaborate your question and add some code of what you are trying to achieve

    – Walucas
    Nov 26 '18 at 13:47














  • 1





    Hello, please elaborate your question and add some code of what you are trying to achieve

    – Walucas
    Nov 26 '18 at 13:47








1




1





Hello, please elaborate your question and add some code of what you are trying to achieve

– Walucas
Nov 26 '18 at 13:47





Hello, please elaborate your question and add some code of what you are trying to achieve

– Walucas
Nov 26 '18 at 13:47












2 Answers
2






active

oldest

votes


















1














Sounds like you are trying to run a filter on a subquery. So put all the code you wish to run first inside the subquery. Then run the filters you wish to apply after that query has finished in the last filter.



Would look something like this:



SELECT *
FROM (
SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
FROM "baseobj_link"
WHERE
"baseobj_link"."is_deleted" = false AND
"baseobj_link"."linkname" = 'cgw_vhost' AND
"baseobj_link"."left_uuid" IN (
SELECT V0."uuid" AS Col1
FROM "structure_cgw" V0
WHERE (
V0."id" IN (
SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
FROM "structure_cgw" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
) AND
V0."is_deleted" = false
)
AND "baseobj_link"."left_type_id" = 6
) AS t1
WHERE t1.id IN (
SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
FROM "baseobj_link" U0
WHERE U0."config_id" IN (2848)
ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
)




From the MYSQL documentation on derived tables:




A derived table is an expression that generates a table within the scope of a query FROM clause. For example, a subquery in a SELECT statement FROM clause is a derived table:



SELECT ... FROM (subquery) [AS] tbl_name ...




Let me know how this works out.






share|improve this answer


























  • It's no a simple case, i need to add filter for all queries to the model. To add this filter to each query in the code is wrong, because there are many places in the code, where query to the model can be built.

    – Sergey
    Nov 26 '18 at 14:20



















0














В своей модели queryset'а дополнительно храним queryset без filter_deleted и переопределяем метод _filter_or_exclude, чтобы тот вызывал _filter_or_exclude у хранимого queryset'а, а потом уже filter_deleted. Также храним флаг фильтрации, чтобы знать когда нужно вызывать базовый _filter_or_exclude, а когда filter_deleted.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53482480%2fhow-can-i-add-filter-to-all-querysets-at-the-end-of-sql-query%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Sounds like you are trying to run a filter on a subquery. So put all the code you wish to run first inside the subquery. Then run the filters you wish to apply after that query has finished in the last filter.



    Would look something like this:



    SELECT *
    FROM (
    SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
    FROM "baseobj_link"
    WHERE
    "baseobj_link"."is_deleted" = false AND
    "baseobj_link"."linkname" = 'cgw_vhost' AND
    "baseobj_link"."left_uuid" IN (
    SELECT V0."uuid" AS Col1
    FROM "structure_cgw" V0
    WHERE (
    V0."id" IN (
    SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
    FROM "structure_cgw" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
    ) AND
    V0."is_deleted" = false
    )
    AND "baseobj_link"."left_type_id" = 6
    ) AS t1
    WHERE t1.id IN (
    SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
    FROM "baseobj_link" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
    )




    From the MYSQL documentation on derived tables:




    A derived table is an expression that generates a table within the scope of a query FROM clause. For example, a subquery in a SELECT statement FROM clause is a derived table:



    SELECT ... FROM (subquery) [AS] tbl_name ...




    Let me know how this works out.






    share|improve this answer


























    • It's no a simple case, i need to add filter for all queries to the model. To add this filter to each query in the code is wrong, because there are many places in the code, where query to the model can be built.

      – Sergey
      Nov 26 '18 at 14:20
















    1














    Sounds like you are trying to run a filter on a subquery. So put all the code you wish to run first inside the subquery. Then run the filters you wish to apply after that query has finished in the last filter.



    Would look something like this:



    SELECT *
    FROM (
    SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
    FROM "baseobj_link"
    WHERE
    "baseobj_link"."is_deleted" = false AND
    "baseobj_link"."linkname" = 'cgw_vhost' AND
    "baseobj_link"."left_uuid" IN (
    SELECT V0."uuid" AS Col1
    FROM "structure_cgw" V0
    WHERE (
    V0."id" IN (
    SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
    FROM "structure_cgw" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
    ) AND
    V0."is_deleted" = false
    )
    AND "baseobj_link"."left_type_id" = 6
    ) AS t1
    WHERE t1.id IN (
    SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
    FROM "baseobj_link" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
    )




    From the MYSQL documentation on derived tables:




    A derived table is an expression that generates a table within the scope of a query FROM clause. For example, a subquery in a SELECT statement FROM clause is a derived table:



    SELECT ... FROM (subquery) [AS] tbl_name ...




    Let me know how this works out.






    share|improve this answer


























    • It's no a simple case, i need to add filter for all queries to the model. To add this filter to each query in the code is wrong, because there are many places in the code, where query to the model can be built.

      – Sergey
      Nov 26 '18 at 14:20














    1












    1








    1







    Sounds like you are trying to run a filter on a subquery. So put all the code you wish to run first inside the subquery. Then run the filters you wish to apply after that query has finished in the last filter.



    Would look something like this:



    SELECT *
    FROM (
    SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
    FROM "baseobj_link"
    WHERE
    "baseobj_link"."is_deleted" = false AND
    "baseobj_link"."linkname" = 'cgw_vhost' AND
    "baseobj_link"."left_uuid" IN (
    SELECT V0."uuid" AS Col1
    FROM "structure_cgw" V0
    WHERE (
    V0."id" IN (
    SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
    FROM "structure_cgw" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
    ) AND
    V0."is_deleted" = false
    )
    AND "baseobj_link"."left_type_id" = 6
    ) AS t1
    WHERE t1.id IN (
    SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
    FROM "baseobj_link" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
    )




    From the MYSQL documentation on derived tables:




    A derived table is an expression that generates a table within the scope of a query FROM clause. For example, a subquery in a SELECT statement FROM clause is a derived table:



    SELECT ... FROM (subquery) [AS] tbl_name ...




    Let me know how this works out.






    share|improve this answer















    Sounds like you are trying to run a filter on a subquery. So put all the code you wish to run first inside the subquery. Then run the filters you wish to apply after that query has finished in the last filter.



    Would look something like this:



    SELECT *
    FROM (
    SELECT "baseobj_link"."left_uuid", "baseobj_link"."right_uuid", "baseobj_link"."right_type_id"
    FROM "baseobj_link"
    WHERE
    "baseobj_link"."is_deleted" = false AND
    "baseobj_link"."linkname" = 'cgw_vhost' AND
    "baseobj_link"."left_uuid" IN (
    SELECT V0."uuid" AS Col1
    FROM "structure_cgw" V0
    WHERE (
    V0."id" IN (
    SELECT DISTINCT ON (U0."uuid") U0."id" AS Col1
    FROM "structure_cgw" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."uuid" ASC, U0."domain_level" DESC, U0."config_id" DESC
    ) AND
    V0."is_deleted" = false
    )
    AND "baseobj_link"."left_type_id" = 6
    ) AS t1
    WHERE t1.id IN (
    SELECT DISTINCT ON (U0."linkname", U0."left_uuid", U0."right_uuid") U0."id" AS Col1
    FROM "baseobj_link" U0
    WHERE U0."config_id" IN (2848)
    ORDER BY U0."linkname" ASC, U0."left_uuid" ASC, U0."right_uuid" ASC, U0."domain_level" ASC, U0."config_id" DESC, U0."is_deleted" DESC
    )




    From the MYSQL documentation on derived tables:




    A derived table is an expression that generates a table within the scope of a query FROM clause. For example, a subquery in a SELECT statement FROM clause is a derived table:



    SELECT ... FROM (subquery) [AS] tbl_name ...




    Let me know how this works out.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 26 '18 at 14:10

























    answered Nov 26 '18 at 13:57









    Robin N.Robin N.

    1474




    1474













    • It's no a simple case, i need to add filter for all queries to the model. To add this filter to each query in the code is wrong, because there are many places in the code, where query to the model can be built.

      – Sergey
      Nov 26 '18 at 14:20



















    • It's no a simple case, i need to add filter for all queries to the model. To add this filter to each query in the code is wrong, because there are many places in the code, where query to the model can be built.

      – Sergey
      Nov 26 '18 at 14:20

















    It's no a simple case, i need to add filter for all queries to the model. To add this filter to each query in the code is wrong, because there are many places in the code, where query to the model can be built.

    – Sergey
    Nov 26 '18 at 14:20





    It's no a simple case, i need to add filter for all queries to the model. To add this filter to each query in the code is wrong, because there are many places in the code, where query to the model can be built.

    – Sergey
    Nov 26 '18 at 14:20













    0














    В своей модели queryset'а дополнительно храним queryset без filter_deleted и переопределяем метод _filter_or_exclude, чтобы тот вызывал _filter_or_exclude у хранимого queryset'а, а потом уже filter_deleted. Также храним флаг фильтрации, чтобы знать когда нужно вызывать базовый _filter_or_exclude, а когда filter_deleted.






    share|improve this answer




























      0














      В своей модели queryset'а дополнительно храним queryset без filter_deleted и переопределяем метод _filter_or_exclude, чтобы тот вызывал _filter_or_exclude у хранимого queryset'а, а потом уже filter_deleted. Также храним флаг фильтрации, чтобы знать когда нужно вызывать базовый _filter_or_exclude, а когда filter_deleted.






      share|improve this answer


























        0












        0








        0







        В своей модели queryset'а дополнительно храним queryset без filter_deleted и переопределяем метод _filter_or_exclude, чтобы тот вызывал _filter_or_exclude у хранимого queryset'а, а потом уже filter_deleted. Также храним флаг фильтрации, чтобы знать когда нужно вызывать базовый _filter_or_exclude, а когда filter_deleted.






        share|improve this answer













        В своей модели queryset'а дополнительно храним queryset без filter_deleted и переопределяем метод _filter_or_exclude, чтобы тот вызывал _filter_or_exclude у хранимого queryset'а, а потом уже filter_deleted. Также храним флаг фильтрации, чтобы знать когда нужно вызывать базовый _filter_or_exclude, а когда filter_deleted.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 10 '18 at 11:31









        SergeySergey

        164




        164






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53482480%2fhow-can-i-add-filter-to-all-querysets-at-the-end-of-sql-query%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)