我怀疑我没有将我的模型导入到需要报告的某个地方,以便同步数据库来获取它们。
我需要在哪里导入我的 models.py(或以其他方式注册我的模型),以便 Django 将它们包含在同步数据库中?
在models.py中,我有:
from django.contrib.auth.models import User
from django.db import models
class CalendarEntry(models.Model):
description = models.TextField()
interval = models.IntegerField()
regular_expression = models.TextField(blank = True)
scratchpad = models.TextField()
should_hide = models.BooleanField()
user = models.ForeignKey(User)
...
当我尝试运行同步数据库时,它不会创建任何表;数据库为空。
christos@christos-virtual-machine:~/dashboard > python manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
christos@christos-virtual-machine:~/dashboard > sqlite3 *.db
SQLite version 3.7.15.2 2013-01-09 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
sqlite>
我可以/应该怎么做才能使 syncdb 适当地填充数据库?