Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

python - Django not creating db tables for models (neither with syncdb nor South)

I have a Django project on a Centos VPS.

I created some models and debugged them so they validate and give no errors. I have them in a "models" folder in my myapp and have added each model to the init file in this directory, for example:

from category import Category

I added the app to settings.py INSTALLED_APPS and ran:

Python manage.py syncdb

It appeared to work fine and added all tables apart from the ones for my app.

I then installed South and added that to INSTALLED_APPS and, tried syncdb again and ran:

Python manage.py schemamigration myapp --initial

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

An example file in "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'

Any ideas what could be going wrong here and why I can't get anything to detect my models?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Run the following commands

python manage.py makemigrations yourappname

python manage.py migrate

Note it works on django 1.7 version for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

1.4m articles

1.4m replys

5 comments

57.0k users

...