简体   繁体   English

如何告诉Django在syncdb上包含我的模型的表?

[英]How can I tell Django to include tables for my models on a syncdb?

I suspect that I have not imported my models into some place they need to be reported for a syncdb to pick them up. 我怀疑我没有将模型导入到某个地方,需要报告它们以便syncdb进行拾取。

Where do I need to import my models.py (or otherwise register my models) so that Django will include them on a syncdb? 我需要在哪里导入我的models.py(或注册我的模型),以便Django将它们包括在syncdb中?

In models.py, I have: 在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)
...

When I try to run a syncdb, it doesn't create any tables; 当我尝试运行syncdb时,它不会创建任何表。 the database is empty. 数据库为空。

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>

What can/should I do so that the syncdb appropriately populates the database? 我可以/应该做些什么,以便syncdb适当地填充数据库?

Is the app in INSTALLED_APPS ? 该应用程序在INSTALLED_APPS吗? Also note that syncdb won't populate tables. 还要注意, syncdb不会填充表。 It will only create them. 只会创建它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM