Import django modules only if they are used.

This commit solves the issue #407.