7.10.1 Capturing Parameters from URLs
parent
df26c82490
commit
434e66e0ae
|
@ -6,8 +6,9 @@ from lists.models import Item, List
|
||||||
def home_page(request):
|
def home_page(request):
|
||||||
return render(request=request, template_name='home.html')
|
return render(request=request, template_name='home.html')
|
||||||
|
|
||||||
def view_list(request):
|
def view_list(request, list_id):
|
||||||
items = Item.objects.all()
|
list_ = List.objects.get(id=list_id)
|
||||||
|
items = Item.objects.filter(list=list_)
|
||||||
return render(request, 'list.html', {'items': items})
|
return render(request, 'list.html', {'items': items})
|
||||||
|
|
||||||
def new_list(request):
|
def new_list(request):
|
||||||
|
|
|
@ -19,5 +19,5 @@ from lists import views
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.home_page, name='home'),
|
url(r'^$', views.home_page, name='home'),
|
||||||
url(r'^lists/new$', views.new_list, name='new_list'),
|
url(r'^lists/new$', views.new_list, name='new_list'),
|
||||||
url(r'^lists/the-only-list-in-the-world/$', views.view_list, name='view_list'),
|
url(r'^lists/(.+)/$', views.view_list, name='view_list'),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue