Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django Models.py数据库设计反馈_Python_Mysql_Database_Django - Fatal编程技术网

Python Django Models.py数据库设计反馈

Python Django Models.py数据库设计反馈,python,mysql,database,django,Python,Mysql,Database,Django,根据我收到的反馈,我重新设计了我的模型,在运行“syncdb”之前需要一些反馈 我关心的主要是外地人和饭桌上的那个男人。ManyTomany字段是否也应该具有through=''值,以及该值应该是多少 任何反馈都将不胜感激 型号 class Restaurant(models.Model): id = models.AutoField(primary_key=True, db_column='id') name = models.CharField(max_length=50L,

根据我收到的反馈,我重新设计了我的模型,在运行“syncdb”之前需要一些反馈

我关心的主要是外地人和饭桌上的那个男人。ManyTomany字段是否也应该具有through=''值,以及该值应该是多少

任何反馈都将不胜感激

型号

class Restaurant(models.Model):
    id = models.AutoField(primary_key=True, db_column='id')
    name = models.CharField(max_length=50L, db_column='name', blank=True)
    address = models.CharField(max_length=100L, blank=True)
    city_id = models.ForeignKey('City', related_name="restaurant_city")
    location_id = models.ForeignKey('Location', related_name="restaurant_location")
    hood_id = models.ForeignKey('Hood', null=True, blank=True, related_name="restaurant_hood")
    listingrole_id = models.ForeignKey('Listingrole', related_name="restaurant_listingrole")
    cuisine_types = models.ManyToManyField('Cuisinetype', null=True, blank=True, related_name="restaurant_cuisinetype")
    class Meta:
        db_table = 'restaurant'

class City(models.Model):
    id = models.AutoField(primary_key=True, db_column='id')
    name = models.CharField(max_length=50L, db_column='city')
    state = models.CharField(max_length=50L, db_column='state', blank=True, null=True)
    class Meta:
        db_table = 'city'

class Cuisinetype(models.Model):
    id = models.AutoField(primary_key=True, db_column='id')
    name = models.CharField(max_length=50L, db_column='cuisine', blank=True) # Field name made lowercase.
    class Meta:
        db_table = 'cuisinetype'

class Location(models.Model):
    id = models.AutoField(primary_key=True, db_column='id')
    name = models.CharField(max_length=50L, db_column='location', blank=False, null=False)
    city = models.ForeignKey('City', related_name="location_city")
    class Meta:
        db_table = 'location'

class Hood(models.Model):
    id = models.AutoField(primary_key=True, db_column='id')
    name = models.CharField(max_length=50L, db_column='hood')
    city = models.ForeignKey('City', related_name='hood_city')
    location = models.ForeignKey('Location', related_name='hood_location')
    class Meta:
        db_table = 'hood'    

class Listingrole(models.Model):
    id = models.AutoField(primary_key=True, db_column='id')
    name = models.CharField(max_length=50L, db_column='listingrole', blank=True) # Field name made lowercase.
    class Meta:
        db_table = 'listingrole'
....

考虑到
coisine\u类型的概念和意义
,您不必使用
通过
关键字建立关系。当有一些关于它自身关系的信息时,你会使用它

根据Django文件:

此选项最常见的用途是当您希望将额外数据与多对多关系关联时

请参见此处的说明: