2017-09-25 71 views
0

我正在尝试迁移数据库,但每次尝试时都会返回下面的错误。我的应用程序名称是'helloservice',但表格是数据库'pulse'中的'customer'。我如何告诉Django不要使用helloservice前缀?如果需要,我按照教程here,现在正在尝试根据自己的需要调整结果。Django迁移返回意外的名称

django.db.utils.ProgrammingError: (1146, "Table 'pulse.helloservice_customer' doesn't exist") 

回答

0

使用Meta类并设置表名。然后表名只设置客户。它不使用前缀(应用程序名称)。然后进行迁移并设置迁移。

class Customer(models.Model): 
    customer_email = models.EmailField() 
    password = models.CharField(max_length=20) 
    ccustomer_first_name = models.CharField(max_length=30) 
    customer_last_name = models.CharField(max_length=30) 

    class Meta: 
     db_table = "customer"