0

i have searched across stackoverflow and i havent been able to come up with an answer.

I have this directory:

project/
    util/
        utility.py
    models.py

So here is a description of what each file does

models.py : contains a list of my django models

utility.py:
from ..models import *
[...]

May i know why i keep getting this error: ValueError: attempted relative import beyond top-level package?

And how can i solve this?

AKJ
  • 749
  • 6
  • 29

2 Answers2

0

There reason is that you are trying to import from non-package directory. That is, project folder is not a package as it does not have init.py. That's why, you are getting this error.

Try this:

from project.models import * 
Jahongir Rahmonov
  • 13,083
  • 10
  • 47
  • 91
0

I managed to solve my problem by following the solution posted by this user:

Django exception : django.core.exceptions.ImproperlyConfigured:

Go upvote his post if it helped you!

AKJ
  • 749
  • 6
  • 29