Practical Django Projects Book Errors for Django 1.4

If you are practicing the code from the book Practical Django Projects with the Django version 1.4, then you will get some errors due to version change. The second edition of the Practical Django Projects is updated for Django 1.1. The latest version of Django at the time of writing this post is Django 1.4.

You can find the complete source code for Django 1.4 at github:
Chapter 3

These are the following errors for Chapter 3. You can find the solutions below the error description.

Chapter 3:

Error Description 1:

No FlatPage matches the given query.

Solution: If you get this error, then the error is not with the version. You have to include a forward slash at the end of the page that you requested. If you remember, in the regular expression you defined in the URLConf(urls.py), you used $ after /

In regular expressions, $ means end of the string. If you want to request a page in this case you put a / at the end of the page path.

For example: Instead of requesting

which will raise the error,
request the page in this manner.

 Error Description 2:

No module named search

Solution: 

If you get this error, then the problem is with the code given in the book due to the version change.

The author tells us to add the following code in the urls.py file.

Change it to

Notice that we have removed the cms. In django-1.4 version, cms is not necessary.

Error Description 3:

In the chapter 3, when you create the SearchKeyword model and as per the instructions of the book, if you  add ‘cms.search’ in the INSTALLED_APPS in the settings.py file in the cms directory and run python manage.py syncdb. You will get this error:

Error: No module names search

Solution:

Instead of adding

in the INSTALLED_APPS in the settings.py file, simply add

Now run python manage.py syncdb.

Error Description 4:

Import Error at /admin/

No module named search.models

Solution:

The author asks us to create admin.py file with some code. He din’t mention the location of the admin.py file. Here our goal is to display the SearchKeyword in the admin interface. So create the admin.py file in the search directory.

Instead of

Use

Countine… Part 2: Chapter 4

One Comment

  1. Practical Django Projects Book Chapter 4 « Edit Distance
    Jun 12, 2012 @ 11:59:40

    [...] Previous… Chapter 3 [...]

    Reply