我創建了一個Django應用程序,並添加models.py一些示範田表myapp_tableName已經存在
1.logo
2.shirt
及其屬性 PID,名稱和org 然後我給他們添加了一個新的屬性價格。並執行命令python manage.py makemigrations和python manage.py遷移我得到了錯誤'表buapp_dealer已經存在。
這裏是我的models.py
from django.db import models
# Create your models here.
class founder(models.Model):
name=models.CharField(max_length=30)
address=models.CharField(max_length=50)
country=models.CharField(max_length=20)
email=models.EmailField(null=True)
headshot=models.ImageField(upload_to='images',null=True)
def __str__(self):
return self.name
__repr__=__str__
class supporter(models.Model):
name=models.CharField(max_length=30)
address=models.CharField(max_length=20)
email=models.EmailField(null=True)
headshot=models.ImageField(upload_to='images',null=True)
def __str__(self):
return self.name
__repr__=__str__
class Admin:
list_display=('name','address','email')
class dealer(models.Model):
name=models.CharField(max_length=30)
address=models.CharField(max_length=40)
#city=models.CharField(max_length=60)
country=models.CharField(max_length=50)
website=models.URLField(null=True)
rep=models.IntegerField(null=True)
def __str__(self):
return self.name
__repr__=__str__
class Admin:
list_display=('name','address','country')
list_filter=('name','country')
ordering=('rep',)
search_fields=('name')
class tshirt(models.Model):
price=models.FloatField(default=0.0)
name=models.CharField(max_length=50,default='default')
fontimage=models.ImageField(upload_to='images/tshirts',null=True)
backimage=models.ImageField(upload_to='images/tshirts',null=True)
def __str__(self):
return str(self.pid)
__repr__=__str__
class Admin:
list_display=('pid','price','fontimage')
list_filter=('price')
ordering=('-pid')
search_fields=('name')
class logo(models.Model):
pid=models.IntegerField()
price=models.FloatField(default=0.0)
org=models.CharField(max_length=50)
img=models.ImageField(upload_to='images/tshirts',null=True)
def __str__(self):
return str(self.pid)
__repr__=__str__
class Admin:
list_display=('pid','price','img')
list_filter=('price')
ordering=('-pid')
search_fields=('org')
class final(models.Model):
pid=models.IntegerField()
price=models.FloatField(default=0.00)
fontimg=models.ImageField(upload_to='images/finals',null=True)
backimg=models.ImageField(upload_to='images/finals',null=True)
def __str__(self):
return str(self.pid)
__repr__=__str__
什麼'manage.py migrate'的輸出? –
您是否嘗試過修改'python manage.py migrate'? – badiya
嘗試發佈模型代碼,最新的並且發佈你的追蹤 – Exprator