Commit
from django.conf.urls import url
from lists import views
urlpatterns = [
url(r'^$', views.home_page, name='home'),
]
from django.urls import path
from lists import views
urlpatterns = [
path('', views.home_page, name='home')
]
Commit
urlpatterns = [
url(r'^$', views.home_page, name='home'),
url(r'^lists/the-only-list-in-the-world/$', views.view_list, name='view_list'),
]
urlpatterns = [
path('', views.home_page, name='home'),
path('lists/the-only-list-in-the-world/', views.view_list, name='view_list'),
]
Chapter 7.8
urlpatterns = [
url(r'^$', views.home_page, name='home'),
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'),
]
urlpatterns = [
path('', views.home_page, name='home'),
path('lists/new', views.new_list, name='new_list'),
path('lists/the-only-list-in-the-world/', views.view_list, name='view_list'),
]
Chapter 7.9
from django.db import models
class List(models.Model):
pass
class Item(models.Model):
text = models.TextField(default='')
list = models.ForeignKey(List, default=None)
from django.db import models
class Item(models.Model):
text = models.TextField(default='')
list = models.ForeignKey('List', default=None, on_delete=models.CASCADE)
class List(models.Model):
pass
Chapter 7.10
urlpatterns = [
url(r'^$', views.home_page, name='home'),
url(r'^lists/new$', views.new_list, name='new_list'),
url(r'^lists/(.+)/$', views.view_list, name='view_list'),
]
urlpatterns = [
path('', views.home_page, name='home'),
path('lists/new', views.new_list, name='new_list'),
path('lists/<int:list_id>/', views.view_list, name='view_list'),
]
Chapter 7.12
urlpatterns = [
url(r'^$', views.home_page, name='home'),
url(r'^lists/new$', views.new_list, name='new_list'),
url(r'^lists/(\d+)/$', views.view_list, name='view_list'),
url(r'^lists/(\d+)/add_item$', views.add_item, name='add_item'),
]
urlpatterns = [
path('', views.home_page, name='home'),
path('lists/new', views.new_list, name='new_list'),
path('lists/<int:list_id>/', views.view_list, name='view_list'),
path('lists/<int:list_id>/add_item', views.add_item, name='add_item')
]