0

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.

0

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

import os,sys
sys.path.append(os.path.dirname(__file__))
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 .