Import django modules only if they are used.

This commit solves the issue #407.
Merge pull request #408 from hectord/correction_import_django

Import django modules only if they are used.