我有2种模式。我跑manage.py执行syncdb但2款只创建ID字段。如何使它产生剩余的字段?请请告知。你的帮助是非常感谢!

下面是我的models.py:

from django.db import models

GENDER_CHOICES = (
    ('M', 'Male')
    , ('F', 'Female')
)

ACTIVATION_CHOICES = (
    ('Y', 'Activate')
    , ('N', 'Inactive')
)

FULL_PART_CHOICES = (
    ('F', 'Full-time')
    , ('P', 'Part-time')
)

# Create your models here.
class Teachers(models.Model):
    id = models.AutoField(primary_key=True, null=False),
    fname = models.CharField(max_length=15, null=False),
    mname = models.CharField(max_length=15, null=False),
    lname = models.CharField(max_length=15, null=False),
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, null=False),
    nric = models.CharField(max_length=12, unique=True, null=False),
    email = models.EmailField(max_length=40, unique=True, null=False),
    dob = models.DateField(null=False),
    unit = models.CharField(max_length=50, null=False),
    block = models.CharField(max_length=50, null=False),
    street = models.CharField(max_length=100, null=False),
    postcode = models.CharField(max_length=10, null=False),
    handphone = models.CharField(max_length=16, unique=True, null=False),
    homephone = models.CharField(max_length=16, null=False),
    activated = models.CharField(max_length=1, choices=ACTIVATION_CHOICES, null=False),
    date_ttc = models.DateField(null=False),
    full_part = models.CharField(max_length=1, choices=FULL_PART_CHOICES, null=False),
    nonce = models.CharField(max_length=40, unique=True, null=False),
    passwd = models.CharField(max_length=40, null=False),
    created_at = models.DateTimeField(auto_now_add=True, null=False),
    updated_at = models.DateTimeField(auto_now=True, null=False),

    def __unicode__(self):
        return "Teacher %s %s %s" % (self.fname, self.mname, self.lname)

# Create your models here.
class Admins(models.Model):
    id = models.AutoField(primary_key=True, null=False),
    fname = models.CharField(max_length=15, null=False),
    mname = models.CharField(max_length=15, null=False),
    lname = models.CharField(max_length=15, null=False),
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, null=False),
    nric = models.CharField(max_length=12, unique=True, null=False),
    email = models.EmailField(max_length=40, unique=True, null=False),
    dob = models.DateField(null=False),
    unit = models.CharField(max_length=50, null=False),
    block = models.CharField(max_length=50, null=False),
    street = models.CharField(max_length=100, null=False),
    postcode = models.CharField(max_length=10, null=False),
    handphone = models.CharField(max_length=16, unique=True, null=False),
    homephone = models.CharField(max_length=16, null=False),
    activated = models.CharField(max_length=1, choices=ACTIVATION_CHOICES, null=False),
    nonce = models.CharField(max_length=40, unique=True, null=False),
    passwd = models.CharField(max_length=40, null=False),
    created_at = models.DateTimeField(auto_now_add=True, null=False),
    updated_at = models.DateTimeField(auto_now=True, null=False),

    def __unicode__(self):
        return "Admin %s %s %s" % (self.fname, self.mname, self.lname)
有帮助吗?

解决方案 2

这是太容易了。有大量的每个字段声明后,多余的逗号。我删除了这些,一切工作正常。

感谢您的答复。

其他提示

您可以删除表,如果你没有对他们的任何资料或使用django-south您可以使用迁移。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top