0

Really frustrating, been tackling unsuccessfully for two days already, Using Django ORM in a python program, trying to working with a mysql DB I have defined

my file structure is

|-- mailparser.py
|-- manager.py
|-- myapp
|   |-- __init__.py
|   |-- __init__.pyc
|   `-- models.py
|-- settings.py

My manager.py looks like:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    print sys.path
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

and my settings.py looks like:

from django.conf import settings

settings.configure(
    DATABASE_ENGINE    = "django.db.backends.mysql",
    DATABASE_NAME      = "mydb",
    DATABASE_USER      = "mysqladmin",
    DATABASE_PASSWORD  = "password",
    DATABASE_HOST      = "192.168.1.1",
    DATABASE_PORT      = "3306",
    INSTALLED_APPS     = ['myapp']
)

from django.db import models
from myapp.models import *

Trying to perform root@pdsc pdscroot]# python manager.py sqlall myapp CommandError: App with label myapp could not be found. Are you sure your INSTALLED_APPS setting is correct?

Shimonbd
  • 84
  • 1
  • 8

1 Answers1

0

You shouldn't be importing models into settings. But you should be sure to add myapp to the INSTALLED_APPS setting.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895