diff --git a/core/templates/core/base.html b/core/templates/core/base.html index 08498a30..6aec6786 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -25,8 +25,8 @@ -
@@ -39,7 +39,7 @@ -
+
{% block content %}{% endblock %}
diff --git a/core/templates/core/child_list.html b/core/templates/core/child_list.html new file mode 100644 index 00000000..f424a310 --- /dev/null +++ b/core/templates/core/child_list.html @@ -0,0 +1,35 @@ +{% extends 'core/base.html' %} +{% load i18n widget_tweaks %} + +{% block title %}Children{% endblock %} + +{% block content %} +

Children

+ + + + + + + + + + + + + {% for child in object_list %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
#First NameLast NameBirth DateActions
{{ child.id }}{{ child.first_name }}{{ child.last_name }}{{ child.birth_date }}modify | delete
No children added.
+{% endblock %} \ No newline at end of file diff --git a/core/urls.py b/core/urls.py index 81f4aed6..17a99ec2 100644 --- a/core/urls.py +++ b/core/urls.py @@ -7,9 +7,11 @@ from . import views urlpatterns = [ url(r'^$', views.Index.as_view(), name='index'), - url(r'child/add/$', views.ChildAdd.as_view(), name='child-add'), - url(r'child/(?P[0-9]+)/$', views.ChildUpdate.as_view(), + + url(r'children/$', views.ChildList.as_view(), name='child-list'), + url(r'children/add/$', views.ChildAdd.as_view(), name='child-add'), + url(r'children/(?P[0-9]+)/$', views.ChildUpdate.as_view(), name='child-update'), - url(r'child/(?P[0-9]+)/delete/$', views.ChildDelete.as_view(), + url(r'children/(?P[0-9]+)/delete/$', views.ChildDelete.as_view(), name='child-delete'), ] diff --git a/core/views.py b/core/views.py index 23b652ac..567428cb 100644 --- a/core/views.py +++ b/core/views.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from django.views.generic.base import TemplateView from django.views.generic.edit import CreateView, UpdateView, DeleteView +from django.views.generic.list import ListView from .models import Child @@ -11,16 +12,20 @@ class Index(TemplateView): template_name = 'core/index.html' +class ChildList(ListView): + model = Child + + class ChildAdd(CreateView): model = Child fields = ['first_name', 'last_name', 'birth_date'] - success_url = '/' + success_url = '/children' class ChildUpdate(UpdateView): model = Child fields = ['first_name', 'last_name', 'birth_date'] - success_url = '/' + success_url = '/children' class ChildDelete(DeleteView):