Django second page not found












1














Can any one tell me why my help page keeps returning page not found please?



Views



from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.


def index(request):
my_dict = {'insert_me':"Hello I am from views.py !"}
return render(request, 'first_app/index.html', context=my_dict)


def help(request):
help_dict = {'help_insert':'HELP PAGE'}
return render(request, 'first_app/help.html', context=help_dict)


First_app urls



from django.urls import path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('', views.help, name='help' ),
]


first_app urls:



from django.contrib import admin
from django.urls import include, path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('first_app/', include('first_app.urls')),
path('admin/', admin.site.urls),
]


there is a template folder with first app_folder both html files are in there.
Have tried http://127.0.0.1:8000/first_app/help
and http://127.0.0.1:8000/help



What am I missing please?










share|improve this question






















  • First_app urls is not correct. You are adding two url in same place. Consider adding path(' add-something-here ', views.help, name='help' ),
    – Bidhan Majhi
    Nov 21 '18 at 5:31
















1














Can any one tell me why my help page keeps returning page not found please?



Views



from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.


def index(request):
my_dict = {'insert_me':"Hello I am from views.py !"}
return render(request, 'first_app/index.html', context=my_dict)


def help(request):
help_dict = {'help_insert':'HELP PAGE'}
return render(request, 'first_app/help.html', context=help_dict)


First_app urls



from django.urls import path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('', views.help, name='help' ),
]


first_app urls:



from django.contrib import admin
from django.urls import include, path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('first_app/', include('first_app.urls')),
path('admin/', admin.site.urls),
]


there is a template folder with first app_folder both html files are in there.
Have tried http://127.0.0.1:8000/first_app/help
and http://127.0.0.1:8000/help



What am I missing please?










share|improve this question






















  • First_app urls is not correct. You are adding two url in same place. Consider adding path(' add-something-here ', views.help, name='help' ),
    – Bidhan Majhi
    Nov 21 '18 at 5:31














1












1








1







Can any one tell me why my help page keeps returning page not found please?



Views



from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.


def index(request):
my_dict = {'insert_me':"Hello I am from views.py !"}
return render(request, 'first_app/index.html', context=my_dict)


def help(request):
help_dict = {'help_insert':'HELP PAGE'}
return render(request, 'first_app/help.html', context=help_dict)


First_app urls



from django.urls import path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('', views.help, name='help' ),
]


first_app urls:



from django.contrib import admin
from django.urls import include, path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('first_app/', include('first_app.urls')),
path('admin/', admin.site.urls),
]


there is a template folder with first app_folder both html files are in there.
Have tried http://127.0.0.1:8000/first_app/help
and http://127.0.0.1:8000/help



What am I missing please?










share|improve this question













Can any one tell me why my help page keeps returning page not found please?



Views



from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.


def index(request):
my_dict = {'insert_me':"Hello I am from views.py !"}
return render(request, 'first_app/index.html', context=my_dict)


def help(request):
help_dict = {'help_insert':'HELP PAGE'}
return render(request, 'first_app/help.html', context=help_dict)


First_app urls



from django.urls import path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('', views.help, name='help' ),
]


first_app urls:



from django.contrib import admin
from django.urls import include, path
from first_app import views

urlpatterns = [
path('', views.index, name='index'),
path('first_app/', include('first_app.urls')),
path('admin/', admin.site.urls),
]


there is a template folder with first app_folder both html files are in there.
Have tried http://127.0.0.1:8000/first_app/help
and http://127.0.0.1:8000/help



What am I missing please?







django python-3.x django-views






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 21:49









iFunction

108112




108112












  • First_app urls is not correct. You are adding two url in same place. Consider adding path(' add-something-here ', views.help, name='help' ),
    – Bidhan Majhi
    Nov 21 '18 at 5:31


















  • First_app urls is not correct. You are adding two url in same place. Consider adding path(' add-something-here ', views.help, name='help' ),
    – Bidhan Majhi
    Nov 21 '18 at 5:31
















First_app urls is not correct. You are adding two url in same place. Consider adding path(' add-something-here ', views.help, name='help' ),
– Bidhan Majhi
Nov 21 '18 at 5:31




First_app urls is not correct. You are adding two url in same place. Consider adding path(' add-something-here ', views.help, name='help' ),
– Bidhan Majhi
Nov 21 '18 at 5:31












2 Answers
2






active

oldest

votes


















1














You are missing to match 'help' path in url patterns.



When you write



urlpatterns = [
path('', views.index, name='index'),
path('', views.help, name='help' ),
]



and access http://127.0.0.1:8000/ , you will be taken to index view and since your second path is similar to first one, second path will never be matched as Django url patterns match starts from the first and ignore the similar paths present later.



to fix this, add your help path to url patterns as below,



urlpatterns = [
path('', views.index, name='index'),
path('help', views.help, name='help' ),
]



and you can access the help page at http://127.0.0.1:8000/help






share|improve this answer





















  • Thank you, it's obvious when you point it out to me now.
    – iFunction
    Nov 26 '18 at 16:20



















0














Your first_app/urls.py doesn't look good.



There's no help path in there.






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%2f53402102%2fdjango-second-page-not-found%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














    You are missing to match 'help' path in url patterns.



    When you write



    urlpatterns = [
    path('', views.index, name='index'),
    path('', views.help, name='help' ),
    ]



    and access http://127.0.0.1:8000/ , you will be taken to index view and since your second path is similar to first one, second path will never be matched as Django url patterns match starts from the first and ignore the similar paths present later.



    to fix this, add your help path to url patterns as below,



    urlpatterns = [
    path('', views.index, name='index'),
    path('help', views.help, name='help' ),
    ]



    and you can access the help page at http://127.0.0.1:8000/help






    share|improve this answer





















    • Thank you, it's obvious when you point it out to me now.
      – iFunction
      Nov 26 '18 at 16:20
















    1














    You are missing to match 'help' path in url patterns.



    When you write



    urlpatterns = [
    path('', views.index, name='index'),
    path('', views.help, name='help' ),
    ]



    and access http://127.0.0.1:8000/ , you will be taken to index view and since your second path is similar to first one, second path will never be matched as Django url patterns match starts from the first and ignore the similar paths present later.



    to fix this, add your help path to url patterns as below,



    urlpatterns = [
    path('', views.index, name='index'),
    path('help', views.help, name='help' ),
    ]



    and you can access the help page at http://127.0.0.1:8000/help






    share|improve this answer





















    • Thank you, it's obvious when you point it out to me now.
      – iFunction
      Nov 26 '18 at 16:20














    1












    1








    1






    You are missing to match 'help' path in url patterns.



    When you write



    urlpatterns = [
    path('', views.index, name='index'),
    path('', views.help, name='help' ),
    ]



    and access http://127.0.0.1:8000/ , you will be taken to index view and since your second path is similar to first one, second path will never be matched as Django url patterns match starts from the first and ignore the similar paths present later.



    to fix this, add your help path to url patterns as below,



    urlpatterns = [
    path('', views.index, name='index'),
    path('help', views.help, name='help' ),
    ]



    and you can access the help page at http://127.0.0.1:8000/help






    share|improve this answer












    You are missing to match 'help' path in url patterns.



    When you write



    urlpatterns = [
    path('', views.index, name='index'),
    path('', views.help, name='help' ),
    ]



    and access http://127.0.0.1:8000/ , you will be taken to index view and since your second path is similar to first one, second path will never be matched as Django url patterns match starts from the first and ignore the similar paths present later.



    to fix this, add your help path to url patterns as below,



    urlpatterns = [
    path('', views.index, name='index'),
    path('help', views.help, name='help' ),
    ]



    and you can access the help page at http://127.0.0.1:8000/help







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 20 '18 at 22:16









    Sbk3824

    104212




    104212












    • Thank you, it's obvious when you point it out to me now.
      – iFunction
      Nov 26 '18 at 16:20


















    • Thank you, it's obvious when you point it out to me now.
      – iFunction
      Nov 26 '18 at 16:20
















    Thank you, it's obvious when you point it out to me now.
    – iFunction
    Nov 26 '18 at 16:20




    Thank you, it's obvious when you point it out to me now.
    – iFunction
    Nov 26 '18 at 16:20













    0














    Your first_app/urls.py doesn't look good.



    There's no help path in there.






    share|improve this answer




























      0














      Your first_app/urls.py doesn't look good.



      There's no help path in there.






      share|improve this answer


























        0












        0








        0






        Your first_app/urls.py doesn't look good.



        There's no help path in there.






        share|improve this answer














        Your first_app/urls.py doesn't look good.



        There's no help path in there.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 20 '18 at 22:31

























        answered Nov 20 '18 at 22:14









        Alex

        31618




        31618






























            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%2f53402102%2fdjango-second-page-not-found%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

            Create new schema in PostgreSQL using DBeaver

            Deepest pit of an array with Javascript: test on Codility

            Fotorealismo