Practical Django Projects. Page 60 Errata

The import command will not work because whoever packaged this application forgot to add the file __init__.py which is what tells python that the folder should be treated as a module. After you add an empty file named __init__.py everything should work as expected.

Also the following 2 lines of code are incorrect:

self.body_html = markdown(self.body)
self.excerpt_html = markdown(self.excerpt)

The problem is that the folder module is called markdown, and then the file that contains the class is called markdown, and the class we need  is called Markdown, notice capital M.

Assuming we want to use the import statement as specified in the book, the 2 lines of code above need be changed to:

self.body_html = markdown.Markdown(self.body).convert()
self.excerpt_html = markdown.Markdown(self.excerpt).convert()

Tags: ,

Leave a Reply