我将类添加到Django应用程序模型中以创建mysql表。我有“下载”表,在“歌曲”表中有“下载”列。
当我想同步数据库时,Django向我返回错误:
CommandError: One or more models did not validate:
mp3mid.downloads: Reverse query name for field 'song' clashes with field 'songs.downloads'. Add a related_name argument to the definition for 'song'.
为什么不可能给表和列起相同的名字?
这是我的models.py:
from django_evolution.mutations import *
from django.db import models
class singers(models.Model):
name = models.CharField(max_length = 255)
category = models.ForeignKey(categories)
class songs(models.Model):
name = models.CharField(max_length = 255)
singer = models.ForeignKey(singers)
downloads = models.IntegerField(max_length = 11)
exclusive = models.BooleanField(default = 0)
hit = models.BooleanField(default = 0)
date = models.DateTimeField(auto_now_add = True)
link = models.CharField(max_length = 255)
class downloads(models.Model):
song = models.ForeignKey(songs)
date = models.DateTimeField(auto_now_add = True)
GCT1015
相关分类