Using Django ORM inside Tornado, "syncdb" doesn't work

I use Django ORM inside Tornado, and everything is going fine, except that "syncdb" is not working.

So this is my directory structure:

APP_NAME/ APP_NAME/ models.py settings.py __init__.py manage.py database.db 

When I do python manage.py syncdb , the message shows:

 Creating tables ... Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s) 

And the database.db file is created (I use splite3), but the tables are not created. It is worth noting that if I introduced some syntax error in models.py , syncdb would complain, so it looks like syncdb can find my models.py . It just does not create tables for some reason.

For your reference, here is my settings.py parameter (the only thing I missed is SECRET_KEY):

 INSTALLED_APPS = ( 'APP_NAME', ) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'database.db', } } 

Thanks.

PS I'm not sure if this is relevant, but I am using Python 3.3.1 + Django 1.5.1 + Tornado 3.0.1

+4
source share
1 answer

if you did

  django-admin startproject foobar 

then your settings should look like this:

  INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'foobar', ) 

then

  python manage.py syncdb 

will provide you

  Creating tables ... Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_groups Creating table auth_user_user_permissions Creating table auth_user Creating table django_content_type Creating table django_session Creating table django_site Creating table foobar_mymodel 
0
source

Source: https://habr.com/ru/post/1480301/


All Articles