Home > Software engineering >  no module named parsing when importing django models to python script
no module named parsing when importing django models to python script

Time:09-08

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?

CodePudding user response:

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

from .models import *
  • Related