Django - The current URL, , didn't match any of these

43,668

The error message when you visit http://localhost:8000/ is expected, because you haven't defined a url pattern for / in your commented code. The tutorial tells you to go to http://localhost:8000/polls/. In your case, change that to http://localhost:8000/mypage/ because you use mypage instead of polls.

The second error No module named views is because you have used the string 'views.home' in your url patterns instead of the callable views.home. Make sure you include the import as well.

from . import views

urlpatterns = [
    url(r'^$', views.home, name='home'),
]

I notice that you are not following the 1.9 tutorial very closely. For example you are using patterns() and strings like 'mypage.views.home', which are both outdated since Django 1.8. I think you'd find it useful to follow the tutorial exactly before you begin changing lots of stuff.

Share:
43,668
Ravi Shanker Reddy
Author by

Ravi Shanker Reddy

BY DAY: Working in office with Perl, Python By night: Having sweet dreams

Updated on July 09, 2022

Comments

  • Ravi Shanker Reddy
    Ravi Shanker Reddy almost 2 years
    from django.conf.urls import include, url, patterns
    from django.contrib import admin
    
    #urlpatterns = [
    #    url(r'^mypage/', include('mypage.urls')),
    #    url(r'^admin/', admin.site.urls),
    #]
    
    
    urlpatterns = patterns('',
    url(r'^$', 'mypage.views.home', name='home'),
    url(r'^admin/', admin.site.urls),
    )
    

    The uncommented code is working fine. But as per tutorials the commented code also should have to work. But its showng an error of "The current url didnt match any of these". The code path is /ownblog/ownblog/urls.py

    urlpatterns = patterns('',
    url(r'^$', 'views.home', name='home'),
    )
    

    The above code is in ownblog/mypage/urls.py

    def home(request):
        return HttpResponse("Hello, world. You're at the polls index.")
    

    The above code is in ownblog/mypage/views.py What I am missing