In views.py, when initially running the pregenerated line

from . import util

failed with relative import error. The standard

from .dir import package

also failed. Deleting __init.py__ also has no effect.

What is another way to import a local file.

1 Answer 1


via https://stackoverflow.com/a/7506029

import os,sys
import util

Adds local directory absolute path to sys to path, removing the from requirement It is hacky, but if all else fails, this works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .