Django does not create db tables for models (neither with syncdb, nor with South)

I have a Django project on CentOS VPS.

I created some models and debugged them so that they would check and not give errors. I have them in the "models" folder in myapp and added each model to the initialization file in this directory, for example:

from import category

I added the application to settings.py INSTALLED_APPSand ran:

Python manage.py syncdb

It seemed to work fine and added all the tables except those that were for my application.

Then I set South and added that to INSTALLED_APPSand, tried to synchronize again and ran:

Python manage.py schemamigration myapp --initial

It generated the file correctly, but there was nothing in it (none of the tables of my models).

Example file in the "models" folder (usertype.py)

from django.db import models

class UserType(models.Model):
    usertype_id = models.PositiveIntegerField(primary_key=True)
    description = models.CharField(max_length=100)
    is_admin = models.BooleanField()
    is_moderator = models.BooleanField()

class Meta:
    app_label = 'myapp'

, , ?

+4
2

. - , . . :

  • INSTALLED_APPS
  • syncdb
  • INSTALLED_APPS *
  • :

    python manage.py schemamigration myapp --initial
    
  • :

    python manage.py migrate
    

:

  • syncdb
  • :

    manage.py convert_to_south myapp

.

* p.s. - , , , . , django INSTALLED_APPS - syncdb ,

. , , , . django, , , :

, :

project/
       myapp/
            models/
                  __init__.py
                  bar.py

bar.py :

from django.db import models

class Foo(models.Model):
    # fields...

    class Meta:
        app_label = 'myapp' #you need this!

__init__.py :

from bar import Foo

, , .

18/08/2014

wontfix, , -, app_label . !

+8

python manage.py makemigrations yourappname

python manage.py migrate

django 1.7 .

+8

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


All Articles