我已经建立了一些模型并在 django admin 中注册了它们
admin.site.register({Cat,Comment,User,Bet,Bid})
但是 Cat 和 Comment 没有任何字段供我添加数据(见图)。有谁知道我做错了什么?
class User(models.Model):
def __unicode__(self):
return self.user
user = models.CharField(max_length=200,null=True, blank=True)
passwd = models.CharField(max_length=100,null=True, blank=True)
join_date = models.DateTimeField('date joined',null=True, blank=True)
balance = models.DecimalField(max_digits=15, decimal_places=5,max_length=100,null=True, blank=True)
bitaddress = models.CharField(max_length=100,null=True, blank=True)
phone = models.CharField(max_length=100,null=True, blank=True)
email = models.EmailField(max_length=100,null=True, blank=True)
img=models.ImageField(upload_to = 'img/user/')
#this is a bet like "I think that the Lions willwin the Superbowl"
class Bet(models.Model):
def __unicode__(self):
return self.position
position = models.CharField(max_length=255,null=True, blank=True)
date = models.DateTimeField('date published',null=True, blank=True)
cat= models.ForeignKey("Cat",null=True,blank=True)
#lookup field for category - maybe dManyToManyo subcategories
class Cat(models.Model):
def __unicode__(self):
return self.cat_name
cat_name = models.CharField(max_length=255)#,null=True, blank=True)
class Bid(models.Model):
def __unicode__(self):
return self.user
user = models.ForeignKey("User",null=True, blank=True)
amt = models.DecimalField('date published',max_digits=15, decimal_places=5,null=True, blank=True)
bet=models.ForeignKey("Bet",null=True, blank=True)
class Comment(models.Model):
def __unicode__(self):
return self.text
user = models.ForeignKey("User",null=True, blank=True)
bet=models.ForeignKey("Bet",null=True, blank=True)
text=models.TextField()#null=True,blank=True)
#parent=models.ForeignKey-->another comment