Skip to content

Commit

Permalink
Updated chapter model templates 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
leifos committed Oct 15, 2014
1 parent e5a5efc commit 5c3fbf0
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 78 deletions.
12 changes: 6 additions & 6 deletions 154/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = 'How to Tango with Django'
html_title = 'How to Tango with Django 1.5.4'

# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = ''
Expand Down Expand Up @@ -199,7 +199,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'How_To_Tango_With_Django.tex', u'How to Tango with Django',
('index', 'How_To_Tango_With_Django.tex', u'How to Tango with Django 1.5.4',
u'Leif Azzopardi and David Maxwell', 'manual'),
]

Expand Down Expand Up @@ -229,7 +229,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'how to tango with django', u'How To Tango With Django',
('index', 'how to tango with django 1.5.4', u'How To Tango With Django 1.5.4',
[u'Leif Azzopardi and David Maxwell'], 1)
]

Expand All @@ -243,8 +243,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'How To Tango With Django', u'How To Tango With Django',
u'Leif Azzopardi and David Maxwell', 'How To Tango With Django', 'A starters Guide to Web Development in Django 1.5',
('index', 'How To Tango With Django 1.5.4', u'How To Tango With Django 1.5.4',
u'Leif Azzopardi and David Maxwell', 'How To Tango With Django 1.5.4', 'A starters Guide to Web Development in Django 1.5.4',
'Miscellaneous'),
]

Expand All @@ -261,7 +261,7 @@
# -- Options for Epub output ---------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = u'How To Tango With Django'
epub_title = u'How To Tango With Django 1.5.4'
epub_author = u'Leif Azzopardi and David Maxwell'
epub_publisher = u'Leif Azzopardi and David Maxwell'
epub_copyright = u'2013, Leif Azzopardi and David Maxwell'
Expand Down
2 changes: 1 addition & 1 deletion 154/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
How To Tango With Django
How To Tango With Django 1.5.4
====================================================

.. toctree::
Expand Down
5 changes: 4 additions & 1 deletion 17/chapters/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,17 @@ Exercises
Now that you've completed the chapter, try out these exercises to reinforce and practice what you have learnt.

* Update the Category model to include the additional attributes, ``views`` and ``likes`` where the default value is zero.
* Re-sync your database, and update your population script so that the Python category has 128 views and 64 likes, the Django category has 64 views and 32 likes, and the Other Frameworks category has 32 views and 16 likes.
* Make the migrations for your app/model, then migrate your database
* Update your population script so that the Python category has 128 views and 64 likes, the Django category has 64 views and 32 likes, and the Other Frameworks category has 32 views and 16 likes.
* Undertake the `part two of official Django tutorial <https://docs.djangoproject.com/en/1.7/intro/tutorial02/>`_ if you have not done so. This will help to reinforce further what you have learnt here, and to learn more about customising the admin interface.
* Customise the Admin Interface - so that when you view the Page model it displays in a list the category, the name of the page and the url.

Hints
.....
If you require some help or inspiration to get these exercises done, these hints will hopefully help you out.

* Modify the ``Category`` model by adding in the fields, ``view`` and ``likes`` as ``IntegerField``s.
* Modify the ``add_cat`` function in the ``populate.py`` script, to take the ``views`` and ``likes``. Once you get the Category c, then you can update the number of views with ``c.views``, and similarly with likes.
* To customise the admin interface, you will need to edit ``rango/admin.py`` and create a ``PageAdmin`` class that inherits from ``admin.ModelAdmin``.
* Within your new ``PageAdmin`` class, add ``list_display = ('title', 'category', 'url')``.
* Finally, register the ``PageAdmin`` class with Django's admin interface. You should modify the line ``admin.site.register(Page)``. Change it to ``admin.site.register(Page, PageAdmin)`` in Rango's ``admin.py`` file.
Expand Down
Loading

0 comments on commit 5c3fbf0

Please sign in to comment.