jayvynl / django-clickhouse-backend

Django clickhouse database backend.
MIT License
130 stars 21 forks source link

Apps aren't loaded yet #24

Closed wangchuntao816 closed 1 year ago

wangchuntao816 commented 1 year ago

Hi, I am just starting on using ClickHouse with Django 3.2.18 ,and Python 3.8.7.But it not worked. I added this in my Database setting:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': APP_CODE + '-dev',
        'USER': 'root',
        'PASSWORD': 'jlpay@159357',
        'HOST': '172.20.4.90',
        'PORT': 13306,
        "init_command": "SET foreign_key_checks = 0;"
    },
    'clickhouse': {
        'ENGINE': 'clickhouse_backend.backend',
        'NAME': 'default',
        'HOST': '172.20.4.90',
        'USER': 'admin',
        'PASSWORD': 'xxxxxx',
        'TEST': {
            'fake_transaction': True
        }
    }
}
DATABASE_ROUTERS = ['dbrouters.ClickHouseRouter']
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

and when I import in databaseroutes.py :

from clickhouse_backend.models import ClickhouseModel

same errors was happened:

Exception has occurred: AppRegistryNotReady
Apps aren't loaded yet.
  File "D:\vscode\opsmanage\opsmanage\conf\dev.py", line 41, in <module>
    from clickhouse_backend.models import ClickhouseModel
  File "D:\vscode\opsmanage\opsmanage\settings.py", line 13, in <module>
    _module = __import__(DJANGO_CONF_MODULE, globals(), locals(), ['*'])
  File "D:\vscode\opsmanage\manage.py", line 27, in <module>
    execute_from_command_line(sys.argv)

expect your's thanks

jayvynl commented 1 year ago

DO NOT post your DB username and password.

You can not use models in your app before your project setup. Please move from clickhouse_backend.models import ClickhouseModel and other relavant code from D:\vscode\opsmanage\opsmanage\conf\dev.py to other place.

wangchuntao816 commented 1 year ago

DO NOT post your DB username and password.

You can not use models in your app before your project setup. Please move and other relavant code from to other place.from clickhouse_backend.models import ClickhouseModel``D:\vscode\opsmanage\opsmanage\conf\dev.py

oh,it is working,thanks!