2013-08-31 63 views
0

我的模型定義如下,當我運行python manage.py sql應用程序時,它什麼也沒有。 我的應用程序名稱是應用程序。當我將模型的內容更改爲教程https://docs.djangoproject.com/en/1.5/intro/tutorial01/時,它提供了正確的sql語句,因此它必須在下面的模型中出現一些錯誤,任何人都可以指出它嗎?模型定義調試在Django

class Applicationinfo(models.Model): 
    applicationinfo_id = models.BigIntegerField(primary_key=True, db_column='ApplicationInfo_id') # Field name made lowercase. 
    mainproduct = models.CharField(max_length=300, db_column='MainProduct') # Field name made lowercase. 
    subproduct = models.CharField(max_length=300, db_column='SubProduct') # Field name made lowercase. 
    appname = models.CharField(max_length=300, db_column='AppName') # Field name made lowercase. 
    employee = models.CharField(max_length=48, db_column='Employee') # Field name made lowercase. 
    employeeid = models.CharField(max_length=24, db_column='Employeeid') # Field name made lowercase. 
    applicantmail = models.CharField(max_length=90, db_column='applicantMail') # Field name made lowercase. 
    mailnotifytimes = models.IntegerField(db_column='MailNotifyTimes') # Field name made lowercase.                           
    applicantim = models.CharField(max_length=48, db_column='ApplicantIM') # Field name made lowercase. 
    applicantmobilephone = models.CharField(max_length=33, db_column='ApplicantMobilephone') # Field name made lowercase. 
    messagenotifytimes = models.IntegerField(db_column='MessageNotifyTimes') # Field name made lowercase. 
    applicantdpt = models.CharField(max_length=300, db_column='ApplicantDPT') # Field name made lowercase. 
    applicationdate = models.DateTimeField(db_column='ApplicationDate') # Field name made lowercase. 
    onlinestorid = models.CharField(max_length=30, db_column='OnlineStorID') # Field name made lowercase. 
    appid = models.BigIntegerField(unique=True, db_column='AppID') # Field name made lowercase. 
    tapesavecopies = models.IntegerField(null=True, db_column='TapeSaveCopies', blank=True) # Field name made lowercase. 
    appowner = models.CharField(max_length=48, db_column='AppOwner', blank=True) # Field name made lowercase. 
    appownermail = models.CharField(max_length=96, db_column='AppOwnerMail', blank=True) # Field name made lowercase. 
    subproductowner = models.CharField(max_length=48, db_column='SubProductOwner', blank=True) # Field name made lowercase. 
    subproductownermail = models.CharField(max_length=96, db_column='SubProductOwnerMail', blank=True) # Field name made lowercase. 
    mainproductowner = models.CharField(max_length=48, db_column='MainProductOwner', blank=True) # Field name made lowercase. 
    mainproductownermail = models.CharField(max_length=96, db_column='MainProductOwnerMail', blank=True) # Field name made lowercase. 
    applicationreason = models.CharField(max_length=500, db_column='ApplicationReason', blank=True) 
    filetype = models.BooleanField(db_column='FileType') 
    applicationstatus = models.IntegerField(db_column='ApplicationStatus') 

    class Meta: 
     db_table = 'applicationinfo' 
     app_label = 'backupcenter1' 
+0

您是否正確導入模型?另外,運行python manage.py syncdb是否會出現錯誤消息? –

+0

是的,如果我將內容更改爲教程中的模型,它會變得正確。 – young001

+1

這不是我問的。您是否從django.db導入模型中導入了模型,並且在運行syncdb時是否收到錯誤消息? –

回答

0

app_label設置爲'backupcenter1',將其刪除。

app_label = 'backupcenter1'意味着,據Django所知,此型號不屬於您的application應用程序,而是屬於backupcenter1應用程序。因此,爲什麼它不顯示在application應用程序的SQL輸出中。


此外,請注意application是一個應用程序的可怕的名字,你可能想要改變它。

+0

如果我運行python manage.py sql backupcenter1,它會告訴CommandError:無法找到帶有標籤backupcenter1的應用程序。你確定你的INSTALLED_APPS設置是正確的嗎? – young001

+0

@ young001我認爲'app_label'告訴Django這個模型屬於'backupcenter1',但它不是一個你有的應用程序,因此是錯誤的。你嘗試刪除'app_label'嗎? –

+0

@ young001這似乎表明該應用程序未在INSTALLED_APPS中列出您的設置,這很可能是問題 –