How do I add parameter in django 2.0 using path
Question:
I’ve installed django version 2.0 and default for urls is path I know that if in django 1.x can be urls and follow with regular expression, how do I use path for parameters instead of urls, and so I dont want to use urls because django by default add path not urls if its can be or use urls still I want to know how to use a path with parameters in django 2.0
here’s my code
from django.urls import include, path
from . import views
urlpatterns = [
path('', views.articles_list),
path('add', views.articles_add),
path('edit', views.articles_edit)
]
Answers:
path('edit/<int:id>', views.articles_edit)
you can add parameters like this
in view
def articles_edit(request, id):
Application urls.py
File Add Following code
path('blog/< int:blogid >', views.blog)
Application views.py
file, add following code:
def blog(request, blogid):
Make sure both place name should be same (blogid)
I’ve installed django version 2.0 and default for urls is path I know that if in django 1.x can be urls and follow with regular expression, how do I use path for parameters instead of urls, and so I dont want to use urls because django by default add path not urls if its can be or use urls still I want to know how to use a path with parameters in django 2.0
here’s my code
from django.urls import include, path
from . import views
urlpatterns = [
path('', views.articles_list),
path('add', views.articles_add),
path('edit', views.articles_edit)
]
path('edit/<int:id>', views.articles_edit)
you can add parameters like this
in view
def articles_edit(request, id):
Application urls.py
File Add Following code
path('blog/< int:blogid >', views.blog)
Application views.py
file, add following code:
def blog(request, blogid):
Make sure both place name should be same (blogid)