I have a non django project for which i would like to use the django models for data access layer.
Added the models lib in requirements.txt
django-model-utils==3.1.1
And code set it up like below:
from django.conf import settings
from django.db import models
settings.configure(
DATABASE_ENGINE='django.db.backends.mysql',
DATABASE_NAME='***',
DATABASE_USER='***',
DATABASE_PASSWORD='***',
DATABASE_HOST='***',
DATABASE_PORT='***')
class Bus(models.Model):
class Meta:
db_table = 'my_custom_bus'
bus_name = models.CharField(max_length=20)
bus_description = models.CharField(max_length=100)
But when i ran the above code, i am getting the following error:
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
In order to fix the above error, i ran:
import django
django.setup()
Now when i try, i get:
Bus doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
Am i missing some setting here or is there any light weight model only lib in python?