python: force non-relative import?

I wanted to make a module called utils/django.py in my project. On the top I have the line:

from django.db import models

However, it tries to import from itself, and that causes an error. I know I can force a relative import with a prepended .:

from .django.db import models

is there any way to force a non-relative import?

Answers


No. You need to explicitly enable absolute imports.

from __future__ import absolute_import

Need Your Help

How to produce valid HTML with JSPX? (not XHTML)

html jsp html5 jspx

When trying to create a HTML page with JSPX you will face the following difficulties:

Jquery - Uncaught TypeError: Cannot use 'in' operator to search for '324' in

php javascript jquery ajax yii

I'm trying to send a Get request by ajax and output json data that is returned by server in html.