Django second page not found
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
add a comment |
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
First_app urls is not correct. You are adding two url in same place. Consider addingpath(' add-something-here ', views.help, name='help' ),
– Bidhan Majhi
Nov 21 at 5:31
add a comment |
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
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
django python-3.x django-views
asked Nov 20 at 21:49
iFunction
108112
108112
First_app urls is not correct. You are adding two url in same place. Consider addingpath(' add-something-here ', views.help, name='help' ),
– Bidhan Majhi
Nov 21 at 5:31
add a comment |
First_app urls is not correct. You are adding two url in same place. Consider addingpath(' add-something-here ', views.help, name='help' ),
– Bidhan Majhi
Nov 21 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 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 at 5:31
add a comment |
2 Answers
2
active
oldest
votes
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
Thank you, it's obvious when you point it out to me now.
– iFunction
Nov 26 at 16:20
add a comment |
Your first_app/urls.py
doesn't look good.
There's no help
path in there.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
Thank you, it's obvious when you point it out to me now.
– iFunction
Nov 26 at 16:20
add a comment |
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
Thank you, it's obvious when you point it out to me now.
– iFunction
Nov 26 at 16:20
add a comment |
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
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
answered Nov 20 at 22:16
Sbk3824
104212
104212
Thank you, it's obvious when you point it out to me now.
– iFunction
Nov 26 at 16:20
add a comment |
Thank you, it's obvious when you point it out to me now.
– iFunction
Nov 26 at 16:20
Thank you, it's obvious when you point it out to me now.
– iFunction
Nov 26 at 16:20
Thank you, it's obvious when you point it out to me now.
– iFunction
Nov 26 at 16:20
add a comment |
Your first_app/urls.py
doesn't look good.
There's no help
path in there.
add a comment |
Your first_app/urls.py
doesn't look good.
There's no help
path in there.
add a comment |
Your first_app/urls.py
doesn't look good.
There's no help
path in there.
Your first_app/urls.py
doesn't look good.
There's no help
path in there.
edited Nov 20 at 22:31
answered Nov 20 at 22:14
Alex
31618
31618
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 at 5:31