When I start developement server
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Then
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^admin/
^blog/
The empty path didn't match any of these.
mysite.urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^blog/', include('blog.urls')),
]
blog/urls.py
pp_name = 'blog'
urlpatterns = [
# post views
url(r'^$', views.post_list, name='post_list'),
url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/'\
r'(?P<post>[-\w]+)/$',
views.post_detail,
name='post_detail'),
]
I suspect something is wrong with my templates This is what tree gives
tree mysite
mysite
├── blog
│ ├── admin.py
│ ├── apps.py
│ ├── __init__.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ ├── __init__.py
│ │ └── __pycache__
│ │ ├── 0001_initial.cpython-36.pyc
│ │ └── __init__.cpython-36.pyc
│ ├── models.py
│ ├── __pycache__
│ │ ├── admin.cpython-36.pyc
│ │ ├── __init__.cpython-36.pyc
│ │ ├── models.cpython-36.pyc
│ │ ├── urls.cpython-36.pyc
│ │ └── views.cpython-36.pyc
│ ├── templates
│ │ └── blog
│ │ ├── base.html
│ │ └── post
│ │ ├── detail.html
│ │ └── list.html
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── db.sqlite3
├── manage.py
└── mysite
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-36.pyc
│ ├── settings.cpython-36.pyc
│ ├── urls.cpython-36.pyc
│ └── wsgi.cpython-36.pyc
├── settings.py
├── urls.py
└── wsgi.py
Your urls not matching the /
path in main urls. Add some view to url regex r'^$'
then it will work. For example take a view named home
. please import related imports.
from . import views
urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^admin/', admin.site.urls),
url(r'^blog/', include('blog.urls')),
]
or you can do like
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('blog.urls')),
]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments