Commit 6ab23ae66ed4b103f1a787ad39fa62a4295cedc8
1 parent
60ffd86c
Instructed to place custom class imports inside functions
Fixes #71. This is needed for Django 1.9 compatibility.
Showing
1 changed file
with
4 additions
and
3 deletions
| @@ -98,15 +98,16 @@ more. | @@ -98,15 +98,16 @@ more. | ||
| 98 | Finally, we'll define a couple of methods in ``my_comment_app/__init__.py`` to | 98 | Finally, we'll define a couple of methods in ``my_comment_app/__init__.py`` to |
| 99 | point Django at these classes we've created:: | 99 | point Django at these classes we've created:: |
| 100 | 100 | ||
| 101 | - from my_comment_app.models import CommentWithTitle | ||
| 102 | - from my_comment_app.forms import CommentFormWithTitle | ||
| 103 | - | ||
| 104 | def get_model(): | 101 | def get_model(): |
| 102 | + from my_comment_app.models import CommentWithTitle | ||
| 105 | return CommentWithTitle | 103 | return CommentWithTitle |
| 106 | 104 | ||
| 107 | def get_form(): | 105 | def get_form(): |
| 106 | + from my_comment_app.forms import CommentFormWithTitle | ||
| 108 | return CommentFormWithTitle | 107 | return CommentFormWithTitle |
| 109 | 108 | ||
| 109 | +The class imports have to be inside functions, as recent Django versions do not | ||
| 110 | +allow importing models in the application root ``__init__.py`` file. | ||
| 110 | 111 | ||
| 111 | .. warning:: | 112 | .. warning:: |
| 112 | 113 |
Please
register
or
login
to post a comment