Practical Django Projects. Page 34 Errata

The code for the model SearchKeyword, which is just introduced on page 34, needs to be changed to account for the decoupling of model and admin definitation that happened on Django 1.0.

Eventhough it was very easy before, Django 1.0, to tell the admin app that you wanted it to generate an admin interface for a model it was pretty ugly. The new way takes a couple more steps at the beginning but I believe in the long run it has a lot of benefits besides that given one of decoupling.

First get rid of the following lines from search/models.py:

class Admin:
    pass

then, navigate to the folder cms/search which you should have created if you followed the steps verbatim, create a file called admin.py and add the following to it:

from cms.search.models import SearchKeyword
from django.contrib import admin

admin.site.register(SearchKeyword)

Save the file, restart the django webserver and you should see a new group on the admin section for the search app.

HTH

Tags:

2 Responses to “Practical Django Projects. Page 34 Errata”

  1. [...] Ubuntitis Boring things from an Ubuntu user « Practical Django Projects. Page 34 Errata [...]

  2. [...] model is using the old way of telling the admin app to include it in the admin section. Read this to know [...]

Leave a Reply