Django default root page stops working when I add my app to urlpatterns in urls.py
I am new to Django and only followed one tutorial on Visual Studio which worked fine.
Now I was trying to create another project on PyCharm and am facing the below problem.
the default Django template sets up fine in Pycharm and I see the default root/landing page when I run the project.
but the moment I add a url for my app in urls.py the default Django page stops working, although both the admin url and myapp urls work fine.
my Urlspatterns is provided below:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^myapp/', include('myapp.urls', namespace='myapp')),
]
the moment I remove the line the default Django landing page starts working again.
I have tried searching online but was unable to find an explanation. Posting it here because I would really like to know why this happens.
django
|
show 4 more comments
I am new to Django and only followed one tutorial on Visual Studio which worked fine.
Now I was trying to create another project on PyCharm and am facing the below problem.
the default Django template sets up fine in Pycharm and I see the default root/landing page when I run the project.
but the moment I add a url for my app in urls.py the default Django page stops working, although both the admin url and myapp urls work fine.
my Urlspatterns is provided below:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^myapp/', include('myapp.urls', namespace='myapp')),
]
the moment I remove the line the default Django landing page starts working again.
I have tried searching online but was unable to find an explanation. Posting it here because I would really like to know why this happens.
django
Have you tried running it in debug mode so you can get the traceback? It would help to know what the error is you're getting.
– Mihai Chelaru
Nov 16 '18 at 2:04
added screenshot to the above question
– nebula_007
Nov 16 '18 at 6:30
That screenshot tells you what the problem is. You need to define a URL pattern for the homepage of the site. Right now you could go to'admin/'
or'myapp/'
but not''
. Add a URL pattern for that that points to a view and see if that fixes it.
– Mihai Chelaru
Nov 16 '18 at 13:08
hi @MihaiChelaru, my question is, when I remove the 'myapp' url definition, then the root '/' url works, even though there is no definition available except for 'admin/' in the urlpatterns generated by the project. it's only when I add a URL in addition to the default 'admin' when the default landing page stops working.
– nebula_007
Nov 17 '18 at 0:28
The answer to that is on the page itself. Just look at the screenshot in the answer below: "You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs. When you added that URL pattern in there the default Django homepage disappears. Add your own homepage as I described, since I presume you want to do that anyways. I'm not sure what the problem is here.
– Mihai Chelaru
Nov 17 '18 at 0:30
|
show 4 more comments
I am new to Django and only followed one tutorial on Visual Studio which worked fine.
Now I was trying to create another project on PyCharm and am facing the below problem.
the default Django template sets up fine in Pycharm and I see the default root/landing page when I run the project.
but the moment I add a url for my app in urls.py the default Django page stops working, although both the admin url and myapp urls work fine.
my Urlspatterns is provided below:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^myapp/', include('myapp.urls', namespace='myapp')),
]
the moment I remove the line the default Django landing page starts working again.
I have tried searching online but was unable to find an explanation. Posting it here because I would really like to know why this happens.
django
I am new to Django and only followed one tutorial on Visual Studio which worked fine.
Now I was trying to create another project on PyCharm and am facing the below problem.
the default Django template sets up fine in Pycharm and I see the default root/landing page when I run the project.
but the moment I add a url for my app in urls.py the default Django page stops working, although both the admin url and myapp urls work fine.
my Urlspatterns is provided below:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^myapp/', include('myapp.urls', namespace='myapp')),
]
the moment I remove the line the default Django landing page starts working again.
I have tried searching online but was unable to find an explanation. Posting it here because I would really like to know why this happens.
django
django
edited Nov 16 '18 at 6:30
nebula_007
asked Nov 16 '18 at 2:02
nebula_007nebula_007
113
113
Have you tried running it in debug mode so you can get the traceback? It would help to know what the error is you're getting.
– Mihai Chelaru
Nov 16 '18 at 2:04
added screenshot to the above question
– nebula_007
Nov 16 '18 at 6:30
That screenshot tells you what the problem is. You need to define a URL pattern for the homepage of the site. Right now you could go to'admin/'
or'myapp/'
but not''
. Add a URL pattern for that that points to a view and see if that fixes it.
– Mihai Chelaru
Nov 16 '18 at 13:08
hi @MihaiChelaru, my question is, when I remove the 'myapp' url definition, then the root '/' url works, even though there is no definition available except for 'admin/' in the urlpatterns generated by the project. it's only when I add a URL in addition to the default 'admin' when the default landing page stops working.
– nebula_007
Nov 17 '18 at 0:28
The answer to that is on the page itself. Just look at the screenshot in the answer below: "You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs. When you added that URL pattern in there the default Django homepage disappears. Add your own homepage as I described, since I presume you want to do that anyways. I'm not sure what the problem is here.
– Mihai Chelaru
Nov 17 '18 at 0:30
|
show 4 more comments
Have you tried running it in debug mode so you can get the traceback? It would help to know what the error is you're getting.
– Mihai Chelaru
Nov 16 '18 at 2:04
added screenshot to the above question
– nebula_007
Nov 16 '18 at 6:30
That screenshot tells you what the problem is. You need to define a URL pattern for the homepage of the site. Right now you could go to'admin/'
or'myapp/'
but not''
. Add a URL pattern for that that points to a view and see if that fixes it.
– Mihai Chelaru
Nov 16 '18 at 13:08
hi @MihaiChelaru, my question is, when I remove the 'myapp' url definition, then the root '/' url works, even though there is no definition available except for 'admin/' in the urlpatterns generated by the project. it's only when I add a URL in addition to the default 'admin' when the default landing page stops working.
– nebula_007
Nov 17 '18 at 0:28
The answer to that is on the page itself. Just look at the screenshot in the answer below: "You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs. When you added that URL pattern in there the default Django homepage disappears. Add your own homepage as I described, since I presume you want to do that anyways. I'm not sure what the problem is here.
– Mihai Chelaru
Nov 17 '18 at 0:30
Have you tried running it in debug mode so you can get the traceback? It would help to know what the error is you're getting.
– Mihai Chelaru
Nov 16 '18 at 2:04
Have you tried running it in debug mode so you can get the traceback? It would help to know what the error is you're getting.
– Mihai Chelaru
Nov 16 '18 at 2:04
added screenshot to the above question
– nebula_007
Nov 16 '18 at 6:30
added screenshot to the above question
– nebula_007
Nov 16 '18 at 6:30
That screenshot tells you what the problem is. You need to define a URL pattern for the homepage of the site. Right now you could go to
'admin/'
or 'myapp/'
but not ''
. Add a URL pattern for that that points to a view and see if that fixes it.– Mihai Chelaru
Nov 16 '18 at 13:08
That screenshot tells you what the problem is. You need to define a URL pattern for the homepage of the site. Right now you could go to
'admin/'
or 'myapp/'
but not ''
. Add a URL pattern for that that points to a view and see if that fixes it.– Mihai Chelaru
Nov 16 '18 at 13:08
hi @MihaiChelaru, my question is, when I remove the 'myapp' url definition, then the root '/' url works, even though there is no definition available except for 'admin/' in the urlpatterns generated by the project. it's only when I add a URL in addition to the default 'admin' when the default landing page stops working.
– nebula_007
Nov 17 '18 at 0:28
hi @MihaiChelaru, my question is, when I remove the 'myapp' url definition, then the root '/' url works, even though there is no definition available except for 'admin/' in the urlpatterns generated by the project. it's only when I add a URL in addition to the default 'admin' when the default landing page stops working.
– nebula_007
Nov 17 '18 at 0:28
The answer to that is on the page itself. Just look at the screenshot in the answer below: "You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs. When you added that URL pattern in there the default Django homepage disappears. Add your own homepage as I described, since I presume you want to do that anyways. I'm not sure what the problem is here.
– Mihai Chelaru
Nov 17 '18 at 0:30
The answer to that is on the page itself. Just look at the screenshot in the answer below: "You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs. When you added that URL pattern in there the default Django homepage disappears. Add your own homepage as I described, since I presume you want to do that anyways. I'm not sure what the problem is here.
– Mihai Chelaru
Nov 17 '18 at 0:30
|
show 4 more comments
1 Answer
1
active
oldest
votes
This page is intended only to show that django is working properly. As soon as you add any url it is disabled.
I would expect the root / default page to stay unless specifically overridden in the urls file, otherwise it ends up displaying an error (image now added)
– nebula_007
Nov 16 '18 at 6:32
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%2f53330430%2fdjango-default-root-page-stops-working-when-i-add-my-app-to-urlpatterns-in-urls%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
This page is intended only to show that django is working properly. As soon as you add any url it is disabled.
I would expect the root / default page to stay unless specifically overridden in the urls file, otherwise it ends up displaying an error (image now added)
– nebula_007
Nov 16 '18 at 6:32
add a comment |
This page is intended only to show that django is working properly. As soon as you add any url it is disabled.
I would expect the root / default page to stay unless specifically overridden in the urls file, otherwise it ends up displaying an error (image now added)
– nebula_007
Nov 16 '18 at 6:32
add a comment |
This page is intended only to show that django is working properly. As soon as you add any url it is disabled.
This page is intended only to show that django is working properly. As soon as you add any url it is disabled.
answered Nov 16 '18 at 2:17
Helio Meira LinsHelio Meira Lins
264
264
I would expect the root / default page to stay unless specifically overridden in the urls file, otherwise it ends up displaying an error (image now added)
– nebula_007
Nov 16 '18 at 6:32
add a comment |
I would expect the root / default page to stay unless specifically overridden in the urls file, otherwise it ends up displaying an error (image now added)
– nebula_007
Nov 16 '18 at 6:32
I would expect the root / default page to stay unless specifically overridden in the urls file, otherwise it ends up displaying an error (image now added)
– nebula_007
Nov 16 '18 at 6:32
I would expect the root / default page to stay unless specifically overridden in the urls file, otherwise it ends up displaying an error (image now added)
– nebula_007
Nov 16 '18 at 6:32
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.
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%2f53330430%2fdjango-default-root-page-stops-working-when-i-add-my-app-to-urlpatterns-in-urls%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
Have you tried running it in debug mode so you can get the traceback? It would help to know what the error is you're getting.
– Mihai Chelaru
Nov 16 '18 at 2:04
added screenshot to the above question
– nebula_007
Nov 16 '18 at 6:30
That screenshot tells you what the problem is. You need to define a URL pattern for the homepage of the site. Right now you could go to
'admin/'
or'myapp/'
but not''
. Add a URL pattern for that that points to a view and see if that fixes it.– Mihai Chelaru
Nov 16 '18 at 13:08
hi @MihaiChelaru, my question is, when I remove the 'myapp' url definition, then the root '/' url works, even though there is no definition available except for 'admin/' in the urlpatterns generated by the project. it's only when I add a URL in addition to the default 'admin' when the default landing page stops working.
– nebula_007
Nov 17 '18 at 0:28
The answer to that is on the page itself. Just look at the screenshot in the answer below: "You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs. When you added that URL pattern in there the default Django homepage disappears. Add your own homepage as I described, since I presume you want to do that anyways. I'm not sure what the problem is here.
– Mihai Chelaru
Nov 17 '18 at 0:30