Django, URL and Views not found












0















I'm using Django 2.1 and testing views.py and urls.py
What I don't understand is why whenever I enter the URL http://127.0.0.1:8000/blog/post_list I get a 404 error message



My top urls.py:



from django.urls import path
from django.contrib import admin
from django.conf.urls import include, url
from organizer import urls as organizer_urls
from blog import urls as blog_urls

urlpatterns = [
path('admin/', admin.site.urls),
path('', include(organizer_urls)),
path('tag/', include(organizer_urls)),
path('startup/', include(organizer_urls)),
path('blog/', include(blog_urls))
]


my application's urls.py



from django.urls import path
from blog.views import post_list, post_detail

urlpatterns = [
path('',
post_list,
name='blog_post_list'),
path(
'<int:year>/<int:month>/<slug:slug>',
post_detail,
name='blog_post_detail'),
]


my application's views.py:



from django.shortcuts import render, get_object_or_404
from .models import Post
# Create your views here.

def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)

def post_detail(request, year, month, slug):
post = get_object_or_404(
Post,
pub_date__year=year,
pub_date__month=month,
slug=slug)
return render(
request,
'blog/post_detail.html',
{'post': post})


the error message is:




Using the URLconf defined in suorganizer_project.urls, Django tried
these URL patterns, in this order:



admin/ tag/tag_list [name='organizer_tag_list'] tag//
startup/startup_list [name='organizer_startup_list'] startup//
[name='organizer_startup_detail'] tag/ startup/ blog/ The empty path
didn't match any of these.




Why ? The url is there:



path('',
post_list,
name='blog_post_list'),


which would take me to post_list views:



def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)


and returns a query for all objects in post --Post.object.all()-- ?



I don't understand what i'm missing, would appreciate your help ! :)










share|improve this question


















  • 1





    path('', post_list, name='blog_post_list'), change this line to path('post_list/', post_list, name='blog_post_list'),

    – Bidhan Majhi
    Nov 26 '18 at 5:42











  • I'm still new to stackoverflow, but how can I upvote your comment ? :) Thanks

    – Taj Ju
    Nov 26 '18 at 19:38











  • you don't have enough reputations to up-vote comments

    – Lemayzeur
    Nov 27 '18 at 3:57
















0















I'm using Django 2.1 and testing views.py and urls.py
What I don't understand is why whenever I enter the URL http://127.0.0.1:8000/blog/post_list I get a 404 error message



My top urls.py:



from django.urls import path
from django.contrib import admin
from django.conf.urls import include, url
from organizer import urls as organizer_urls
from blog import urls as blog_urls

urlpatterns = [
path('admin/', admin.site.urls),
path('', include(organizer_urls)),
path('tag/', include(organizer_urls)),
path('startup/', include(organizer_urls)),
path('blog/', include(blog_urls))
]


my application's urls.py



from django.urls import path
from blog.views import post_list, post_detail

urlpatterns = [
path('',
post_list,
name='blog_post_list'),
path(
'<int:year>/<int:month>/<slug:slug>',
post_detail,
name='blog_post_detail'),
]


my application's views.py:



from django.shortcuts import render, get_object_or_404
from .models import Post
# Create your views here.

def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)

def post_detail(request, year, month, slug):
post = get_object_or_404(
Post,
pub_date__year=year,
pub_date__month=month,
slug=slug)
return render(
request,
'blog/post_detail.html',
{'post': post})


the error message is:




Using the URLconf defined in suorganizer_project.urls, Django tried
these URL patterns, in this order:



admin/ tag/tag_list [name='organizer_tag_list'] tag//
startup/startup_list [name='organizer_startup_list'] startup//
[name='organizer_startup_detail'] tag/ startup/ blog/ The empty path
didn't match any of these.




Why ? The url is there:



path('',
post_list,
name='blog_post_list'),


which would take me to post_list views:



def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)


and returns a query for all objects in post --Post.object.all()-- ?



I don't understand what i'm missing, would appreciate your help ! :)










share|improve this question


















  • 1





    path('', post_list, name='blog_post_list'), change this line to path('post_list/', post_list, name='blog_post_list'),

    – Bidhan Majhi
    Nov 26 '18 at 5:42











  • I'm still new to stackoverflow, but how can I upvote your comment ? :) Thanks

    – Taj Ju
    Nov 26 '18 at 19:38











  • you don't have enough reputations to up-vote comments

    – Lemayzeur
    Nov 27 '18 at 3:57














0












0








0








I'm using Django 2.1 and testing views.py and urls.py
What I don't understand is why whenever I enter the URL http://127.0.0.1:8000/blog/post_list I get a 404 error message



My top urls.py:



from django.urls import path
from django.contrib import admin
from django.conf.urls import include, url
from organizer import urls as organizer_urls
from blog import urls as blog_urls

urlpatterns = [
path('admin/', admin.site.urls),
path('', include(organizer_urls)),
path('tag/', include(organizer_urls)),
path('startup/', include(organizer_urls)),
path('blog/', include(blog_urls))
]


my application's urls.py



from django.urls import path
from blog.views import post_list, post_detail

urlpatterns = [
path('',
post_list,
name='blog_post_list'),
path(
'<int:year>/<int:month>/<slug:slug>',
post_detail,
name='blog_post_detail'),
]


my application's views.py:



from django.shortcuts import render, get_object_or_404
from .models import Post
# Create your views here.

def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)

def post_detail(request, year, month, slug):
post = get_object_or_404(
Post,
pub_date__year=year,
pub_date__month=month,
slug=slug)
return render(
request,
'blog/post_detail.html',
{'post': post})


the error message is:




Using the URLconf defined in suorganizer_project.urls, Django tried
these URL patterns, in this order:



admin/ tag/tag_list [name='organizer_tag_list'] tag//
startup/startup_list [name='organizer_startup_list'] startup//
[name='organizer_startup_detail'] tag/ startup/ blog/ The empty path
didn't match any of these.




Why ? The url is there:



path('',
post_list,
name='blog_post_list'),


which would take me to post_list views:



def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)


and returns a query for all objects in post --Post.object.all()-- ?



I don't understand what i'm missing, would appreciate your help ! :)










share|improve this question














I'm using Django 2.1 and testing views.py and urls.py
What I don't understand is why whenever I enter the URL http://127.0.0.1:8000/blog/post_list I get a 404 error message



My top urls.py:



from django.urls import path
from django.contrib import admin
from django.conf.urls import include, url
from organizer import urls as organizer_urls
from blog import urls as blog_urls

urlpatterns = [
path('admin/', admin.site.urls),
path('', include(organizer_urls)),
path('tag/', include(organizer_urls)),
path('startup/', include(organizer_urls)),
path('blog/', include(blog_urls))
]


my application's urls.py



from django.urls import path
from blog.views import post_list, post_detail

urlpatterns = [
path('',
post_list,
name='blog_post_list'),
path(
'<int:year>/<int:month>/<slug:slug>',
post_detail,
name='blog_post_detail'),
]


my application's views.py:



from django.shortcuts import render, get_object_or_404
from .models import Post
# Create your views here.

def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)

def post_detail(request, year, month, slug):
post = get_object_or_404(
Post,
pub_date__year=year,
pub_date__month=month,
slug=slug)
return render(
request,
'blog/post_detail.html',
{'post': post})


the error message is:




Using the URLconf defined in suorganizer_project.urls, Django tried
these URL patterns, in this order:



admin/ tag/tag_list [name='organizer_tag_list'] tag//
startup/startup_list [name='organizer_startup_list'] startup//
[name='organizer_startup_detail'] tag/ startup/ blog/ The empty path
didn't match any of these.




Why ? The url is there:



path('',
post_list,
name='blog_post_list'),


which would take me to post_list views:



def post_list(request):
return render(
request,
'blog/post_list.html',
{'post_list':Post.object.all()}
)


and returns a query for all objects in post --Post.object.all()-- ?



I don't understand what i'm missing, would appreciate your help ! :)







django django-views url-pattern






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 '18 at 0:05









Taj JuTaj Ju

153




153








  • 1





    path('', post_list, name='blog_post_list'), change this line to path('post_list/', post_list, name='blog_post_list'),

    – Bidhan Majhi
    Nov 26 '18 at 5:42











  • I'm still new to stackoverflow, but how can I upvote your comment ? :) Thanks

    – Taj Ju
    Nov 26 '18 at 19:38











  • you don't have enough reputations to up-vote comments

    – Lemayzeur
    Nov 27 '18 at 3:57














  • 1





    path('', post_list, name='blog_post_list'), change this line to path('post_list/', post_list, name='blog_post_list'),

    – Bidhan Majhi
    Nov 26 '18 at 5:42











  • I'm still new to stackoverflow, but how can I upvote your comment ? :) Thanks

    – Taj Ju
    Nov 26 '18 at 19:38











  • you don't have enough reputations to up-vote comments

    – Lemayzeur
    Nov 27 '18 at 3:57








1




1





path('', post_list, name='blog_post_list'), change this line to path('post_list/', post_list, name='blog_post_list'),

– Bidhan Majhi
Nov 26 '18 at 5:42





path('', post_list, name='blog_post_list'), change this line to path('post_list/', post_list, name='blog_post_list'),

– Bidhan Majhi
Nov 26 '18 at 5:42













I'm still new to stackoverflow, but how can I upvote your comment ? :) Thanks

– Taj Ju
Nov 26 '18 at 19:38





I'm still new to stackoverflow, but how can I upvote your comment ? :) Thanks

– Taj Ju
Nov 26 '18 at 19:38













you don't have enough reputations to up-vote comments

– Lemayzeur
Nov 27 '18 at 3:57





you don't have enough reputations to up-vote comments

– Lemayzeur
Nov 27 '18 at 3:57












1 Answer
1






active

oldest

votes


















0














post_list is not in your URL pattern, but it is your function name. If you access the URL that way: 127.0.0.1:8000/blog/ it will work and call post_list() view based on this pattern



path('',
post_list,
name='blog_post_list'),


If you want to have your URL works, just edit your pattern the following way by adding the post_list string.



path('post_list',
post_list,
name='blog_post_list'),





share|improve this answer
























  • Many thanks @Lemayzeur, I missed that fact that my '' in the urlpatterns comes after /blog Thanks for the clarification Cheers

    – Taj Ju
    Nov 26 '18 at 19:37













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%2f53473256%2fdjango-url-and-views-not-found%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









0














post_list is not in your URL pattern, but it is your function name. If you access the URL that way: 127.0.0.1:8000/blog/ it will work and call post_list() view based on this pattern



path('',
post_list,
name='blog_post_list'),


If you want to have your URL works, just edit your pattern the following way by adding the post_list string.



path('post_list',
post_list,
name='blog_post_list'),





share|improve this answer
























  • Many thanks @Lemayzeur, I missed that fact that my '' in the urlpatterns comes after /blog Thanks for the clarification Cheers

    – Taj Ju
    Nov 26 '18 at 19:37


















0














post_list is not in your URL pattern, but it is your function name. If you access the URL that way: 127.0.0.1:8000/blog/ it will work and call post_list() view based on this pattern



path('',
post_list,
name='blog_post_list'),


If you want to have your URL works, just edit your pattern the following way by adding the post_list string.



path('post_list',
post_list,
name='blog_post_list'),





share|improve this answer
























  • Many thanks @Lemayzeur, I missed that fact that my '' in the urlpatterns comes after /blog Thanks for the clarification Cheers

    – Taj Ju
    Nov 26 '18 at 19:37
















0












0








0







post_list is not in your URL pattern, but it is your function name. If you access the URL that way: 127.0.0.1:8000/blog/ it will work and call post_list() view based on this pattern



path('',
post_list,
name='blog_post_list'),


If you want to have your URL works, just edit your pattern the following way by adding the post_list string.



path('post_list',
post_list,
name='blog_post_list'),





share|improve this answer













post_list is not in your URL pattern, but it is your function name. If you access the URL that way: 127.0.0.1:8000/blog/ it will work and call post_list() view based on this pattern



path('',
post_list,
name='blog_post_list'),


If you want to have your URL works, just edit your pattern the following way by adding the post_list string.



path('post_list',
post_list,
name='blog_post_list'),






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 26 '18 at 0:10









LemayzeurLemayzeur

5,3301834




5,3301834













  • Many thanks @Lemayzeur, I missed that fact that my '' in the urlpatterns comes after /blog Thanks for the clarification Cheers

    – Taj Ju
    Nov 26 '18 at 19:37





















  • Many thanks @Lemayzeur, I missed that fact that my '' in the urlpatterns comes after /blog Thanks for the clarification Cheers

    – Taj Ju
    Nov 26 '18 at 19:37



















Many thanks @Lemayzeur, I missed that fact that my '' in the urlpatterns comes after /blog Thanks for the clarification Cheers

– Taj Ju
Nov 26 '18 at 19:37







Many thanks @Lemayzeur, I missed that fact that my '' in the urlpatterns comes after /blog Thanks for the clarification Cheers

– Taj Ju
Nov 26 '18 at 19:37






















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%2f53473256%2fdjango-url-and-views-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

Costa Masnaga

Fotorealismo

Sidney Franklin