from django.db import models
# Create your models here.
#用户表
class User(models.Model):
username = models.CharField(max_length=32,verbose_name='用户名')
password = models.CharField(max_length=32,verbose_name='密码')
#choices参数,针对一些可以列举完全可能性的片段
gender_choices = ((1,'男'),(2,'女'),(3,'保密'))
gender = models.IntegerField(choices=gender_choices)
email = models.EmailField(null=True)
#英雄表
class Hero(models.Model):
hero_name = models.CharField(max_length=32)
hero_background_information = models.TextField()
#英雄和阵营表是1对多关系,外键放在多的一方
camp = models.ForeignKey(to='Camp')
#英雄台词
class hero_dialogu(models.Model):
#英雄台词
hero_dialogues = models.CharField(max_length=255)
#英雄和英雄台词表1对多关系,外键放在多的一方
hero = models.ForeignKey(to='Hero')
#阵营表-背景介绍
class Camp(models.Model):
camp_choices = ((1,'艾欧尼亚'),(2,'洛克萨斯'),(3,'均衡教派'))
camp = models.IntegerField(choices=camp_choices)
camp_background_information = models.TextField(null=True)
#推荐装备表
class RecommendEquipment(models.Model):
equipment = models.CharField(max_length=32)
equipment_information = models.TextField(null=True)
#英雄和推荐装备,本来应该放在查询频率较高的英雄一方
#这里练习放在装备表中
hero = models.ManyToManyField(to='Hero')
python学习笔记-django(3)--orm创建表关系
最新推荐文章于 2023-01-04 16:06:17 发布