Django NoReverseMatch: Reverse not found, not a valid view function or pattern name











up vote
1
down vote

favorite












I have a Django app that resolved urls correctly as of a few days ago but no longer does so. Looking at my git log nothing pertaining to urls changed, but all of a sudden is appears Django is not loading urls for the application in question.



The debug page shows the app is installed (though it's last in the load order, if that matters). The behavior I'm seeing implies that Django is either ignoring or overriding only some parts of the app's urls.py file though-- some urls defined by the app in the same urls.py file do load!



Namespacing: While it would likely make short work of the issue, I'm trying to override existing non-namespaced urls and cannot refactor the code that exists outside the scope of my app to establish the namespace. So that is not an option. I simply want to trump the parent project's url resolution so my views are called instead of stock.



Template tags: They appear correct, but more importantly this isn't about a failure to render, it's about the url supposedly not existing in the first place.



Example: The view name in question is 'objects', but none of these object views work. As an example of the source of my confusion, here's the content of the 404 error I'm getting when I go to a bogus page (/efwefwefijiefj/):



Using the URLconf defined in web.urls, Django tried these URL patterns, in this order:
^objects/detail/(?P<slug>[wd-]+)/(?P<pk>[0-9]+)/$ [name='object-detail']
^objects/create/$ [name='object-create']
^objects/$ [name='objects']
...


We can both see that objects is a named view, the app it belongs to exists, and it's one of the first URLs evaluated. But if you try to actually go to the /objects/ page, that's when you get the NoReverseMatch error.



Any help would be appreciated!










share|improve this question
























  • Post your config please.
    – Selcuk
    Nov 19 at 2:11










  • Check your url template tags
    – bdoubleu
    Nov 19 at 10:30















up vote
1
down vote

favorite












I have a Django app that resolved urls correctly as of a few days ago but no longer does so. Looking at my git log nothing pertaining to urls changed, but all of a sudden is appears Django is not loading urls for the application in question.



The debug page shows the app is installed (though it's last in the load order, if that matters). The behavior I'm seeing implies that Django is either ignoring or overriding only some parts of the app's urls.py file though-- some urls defined by the app in the same urls.py file do load!



Namespacing: While it would likely make short work of the issue, I'm trying to override existing non-namespaced urls and cannot refactor the code that exists outside the scope of my app to establish the namespace. So that is not an option. I simply want to trump the parent project's url resolution so my views are called instead of stock.



Template tags: They appear correct, but more importantly this isn't about a failure to render, it's about the url supposedly not existing in the first place.



Example: The view name in question is 'objects', but none of these object views work. As an example of the source of my confusion, here's the content of the 404 error I'm getting when I go to a bogus page (/efwefwefijiefj/):



Using the URLconf defined in web.urls, Django tried these URL patterns, in this order:
^objects/detail/(?P<slug>[wd-]+)/(?P<pk>[0-9]+)/$ [name='object-detail']
^objects/create/$ [name='object-create']
^objects/$ [name='objects']
...


We can both see that objects is a named view, the app it belongs to exists, and it's one of the first URLs evaluated. But if you try to actually go to the /objects/ page, that's when you get the NoReverseMatch error.



Any help would be appreciated!










share|improve this question
























  • Post your config please.
    – Selcuk
    Nov 19 at 2:11










  • Check your url template tags
    – bdoubleu
    Nov 19 at 10:30













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a Django app that resolved urls correctly as of a few days ago but no longer does so. Looking at my git log nothing pertaining to urls changed, but all of a sudden is appears Django is not loading urls for the application in question.



The debug page shows the app is installed (though it's last in the load order, if that matters). The behavior I'm seeing implies that Django is either ignoring or overriding only some parts of the app's urls.py file though-- some urls defined by the app in the same urls.py file do load!



Namespacing: While it would likely make short work of the issue, I'm trying to override existing non-namespaced urls and cannot refactor the code that exists outside the scope of my app to establish the namespace. So that is not an option. I simply want to trump the parent project's url resolution so my views are called instead of stock.



Template tags: They appear correct, but more importantly this isn't about a failure to render, it's about the url supposedly not existing in the first place.



Example: The view name in question is 'objects', but none of these object views work. As an example of the source of my confusion, here's the content of the 404 error I'm getting when I go to a bogus page (/efwefwefijiefj/):



Using the URLconf defined in web.urls, Django tried these URL patterns, in this order:
^objects/detail/(?P<slug>[wd-]+)/(?P<pk>[0-9]+)/$ [name='object-detail']
^objects/create/$ [name='object-create']
^objects/$ [name='objects']
...


We can both see that objects is a named view, the app it belongs to exists, and it's one of the first URLs evaluated. But if you try to actually go to the /objects/ page, that's when you get the NoReverseMatch error.



Any help would be appreciated!










share|improve this question















I have a Django app that resolved urls correctly as of a few days ago but no longer does so. Looking at my git log nothing pertaining to urls changed, but all of a sudden is appears Django is not loading urls for the application in question.



The debug page shows the app is installed (though it's last in the load order, if that matters). The behavior I'm seeing implies that Django is either ignoring or overriding only some parts of the app's urls.py file though-- some urls defined by the app in the same urls.py file do load!



Namespacing: While it would likely make short work of the issue, I'm trying to override existing non-namespaced urls and cannot refactor the code that exists outside the scope of my app to establish the namespace. So that is not an option. I simply want to trump the parent project's url resolution so my views are called instead of stock.



Template tags: They appear correct, but more importantly this isn't about a failure to render, it's about the url supposedly not existing in the first place.



Example: The view name in question is 'objects', but none of these object views work. As an example of the source of my confusion, here's the content of the 404 error I'm getting when I go to a bogus page (/efwefwefijiefj/):



Using the URLconf defined in web.urls, Django tried these URL patterns, in this order:
^objects/detail/(?P<slug>[wd-]+)/(?P<pk>[0-9]+)/$ [name='object-detail']
^objects/create/$ [name='object-create']
^objects/$ [name='objects']
...


We can both see that objects is a named view, the app it belongs to exists, and it's one of the first URLs evaluated. But if you try to actually go to the /objects/ page, that's when you get the NoReverseMatch error.



Any help would be appreciated!







python django






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 18:25

























asked Nov 19 at 1:44









Ivan

7101515




7101515












  • Post your config please.
    – Selcuk
    Nov 19 at 2:11










  • Check your url template tags
    – bdoubleu
    Nov 19 at 10:30


















  • Post your config please.
    – Selcuk
    Nov 19 at 2:11










  • Check your url template tags
    – bdoubleu
    Nov 19 at 10:30
















Post your config please.
– Selcuk
Nov 19 at 2:11




Post your config please.
– Selcuk
Nov 19 at 2:11












Check your url template tags
– bdoubleu
Nov 19 at 10:30




Check your url template tags
– bdoubleu
Nov 19 at 10:30












1 Answer
1






active

oldest

votes

















up vote
0
down vote













I checked all the template tags, the url patterns, messed around with the order of app loading and url resolution. Nothing worked.



As I started stripping every URL template tag I had written out of my application I came across another NoReverseMatch for a reverse() on a FormView's success_url.



That was one of the last changes I had made but that one should absolutely exist; figuring this whole thing was an error that manifested due to Django loading things inconsistently/out-of-order I deferred reversal of that url by changing it to a reverse_lazy().



Everything works now. A prematurely-reversed URL as an attribute of a class-based view that had nothing to do with the objects view itself is what resulted in this incredibly opaque error.



I should have known better but the initial diagnostic information Django provided was of no help at all, so I'm leaving this out there as something else to check if you encounter this error-- most other questions/answers pertain to trivial regex errors in urls.py or misuse of template tags.



Don't set class-based view attributes to the result of reverse()-- use reverse_lazy() to account for all apps not having loaded yet!






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%2f53367275%2fdjango-noreversematch-reverse-not-found-not-a-valid-view-function-or-pattern-n%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I checked all the template tags, the url patterns, messed around with the order of app loading and url resolution. Nothing worked.



    As I started stripping every URL template tag I had written out of my application I came across another NoReverseMatch for a reverse() on a FormView's success_url.



    That was one of the last changes I had made but that one should absolutely exist; figuring this whole thing was an error that manifested due to Django loading things inconsistently/out-of-order I deferred reversal of that url by changing it to a reverse_lazy().



    Everything works now. A prematurely-reversed URL as an attribute of a class-based view that had nothing to do with the objects view itself is what resulted in this incredibly opaque error.



    I should have known better but the initial diagnostic information Django provided was of no help at all, so I'm leaving this out there as something else to check if you encounter this error-- most other questions/answers pertain to trivial regex errors in urls.py or misuse of template tags.



    Don't set class-based view attributes to the result of reverse()-- use reverse_lazy() to account for all apps not having loaded yet!






    share|improve this answer

























      up vote
      0
      down vote













      I checked all the template tags, the url patterns, messed around with the order of app loading and url resolution. Nothing worked.



      As I started stripping every URL template tag I had written out of my application I came across another NoReverseMatch for a reverse() on a FormView's success_url.



      That was one of the last changes I had made but that one should absolutely exist; figuring this whole thing was an error that manifested due to Django loading things inconsistently/out-of-order I deferred reversal of that url by changing it to a reverse_lazy().



      Everything works now. A prematurely-reversed URL as an attribute of a class-based view that had nothing to do with the objects view itself is what resulted in this incredibly opaque error.



      I should have known better but the initial diagnostic information Django provided was of no help at all, so I'm leaving this out there as something else to check if you encounter this error-- most other questions/answers pertain to trivial regex errors in urls.py or misuse of template tags.



      Don't set class-based view attributes to the result of reverse()-- use reverse_lazy() to account for all apps not having loaded yet!






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I checked all the template tags, the url patterns, messed around with the order of app loading and url resolution. Nothing worked.



        As I started stripping every URL template tag I had written out of my application I came across another NoReverseMatch for a reverse() on a FormView's success_url.



        That was one of the last changes I had made but that one should absolutely exist; figuring this whole thing was an error that manifested due to Django loading things inconsistently/out-of-order I deferred reversal of that url by changing it to a reverse_lazy().



        Everything works now. A prematurely-reversed URL as an attribute of a class-based view that had nothing to do with the objects view itself is what resulted in this incredibly opaque error.



        I should have known better but the initial diagnostic information Django provided was of no help at all, so I'm leaving this out there as something else to check if you encounter this error-- most other questions/answers pertain to trivial regex errors in urls.py or misuse of template tags.



        Don't set class-based view attributes to the result of reverse()-- use reverse_lazy() to account for all apps not having loaded yet!






        share|improve this answer












        I checked all the template tags, the url patterns, messed around with the order of app loading and url resolution. Nothing worked.



        As I started stripping every URL template tag I had written out of my application I came across another NoReverseMatch for a reverse() on a FormView's success_url.



        That was one of the last changes I had made but that one should absolutely exist; figuring this whole thing was an error that manifested due to Django loading things inconsistently/out-of-order I deferred reversal of that url by changing it to a reverse_lazy().



        Everything works now. A prematurely-reversed URL as an attribute of a class-based view that had nothing to do with the objects view itself is what resulted in this incredibly opaque error.



        I should have known better but the initial diagnostic information Django provided was of no help at all, so I'm leaving this out there as something else to check if you encounter this error-- most other questions/answers pertain to trivial regex errors in urls.py or misuse of template tags.



        Don't set class-based view attributes to the result of reverse()-- use reverse_lazy() to account for all apps not having loaded yet!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 at 20:50









        Ivan

        7101515




        7101515






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53367275%2fdjango-noreversematch-reverse-not-found-not-a-valid-view-function-or-pattern-n%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

            "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

            Alcedinidae

            RAC Tourist Trophy