no module named parsing when importing django models to python script

Question:

Hi there Im having issues importing my models into my application called parsing

project structure looks like:

manage.py
enumproject/
db.sqlite3
parsing/

with enumproject/settings.py I have it in INSTALLED_APPS:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    #'parsing',
    'parsing.apps.ParsingConfig',
]

models.py under parsing/models.py has:

from enumproject import models

# Create your models here.

class tbl(models.Model):
    nm=models.CharField(max_length=20, unique=True)
    dtAdded=models.DateTimeField()

#etc...

im attempting to run parse.py from parsing/parse.py

from parsing.models import *

#python code here

when I run this file, I get:

Traceback (most recent call last):
  File "parse.py", line 8, in <module>
    from parsing.models import *
ModuleNotFoundError: No module named 'parsing'

thoughts?

Asked By: Jshee

||

Answers:

If it is in the same folder, then don’t use name of the application:

from .models import *
Answered By: NixonSparrow
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.