update
I apologise for yet another simple Django question but I cannot find what I'm after.
Project: Blog I'm trying to URL design to the app using Django 2.0
I apologise for yet another simple Django question but I cannot find what I'm after.
Project: Blog I'm trying to URL design to the app using Django 2.0
Django 2.0 adds the new path
function for urls : https://docs.djangoproject.com/fr/2.0/ref/urls/#path
path
doesn't use regex anymore.
You have two solutions
1) Use path
and change the url pattern to new django format
from django.urls import path
urlpatterns = [
url('/post/<int:pk>/', ...)
]
2) Keep you regex and use re_path
from django.urls import re_path
urlpatterns = [
re_path('^/post/(?<pk>[0-9]+)/$', ...)
]
Note that using url
function is still possible but will be likely be deprecated in a next version. It has been renamed into re_path
in Django 2.0
update you urls.py file.
you need to import view_post
in urls.py file
from blog.views import view_post
#from appname.file.py import (class/func)name
As you are using view_post
in urls.py so you also need to import it in that file.