from django.db import models

# Create your models here.

class userType(models.Model):

name=models.CharField(max_length=32)

def __str__(self):

return self.name#可以返回名字了

class userInfo(models.Model):

nid=models.AutoField(primary_key=True)

name=models.CharField(max_length=32)

email=models.EmailField()

text=models.TextField()

image=models.ImageField()

user_type=models.ForeignKey(userType,null=True,blank=True)

ll=models.OneToOneField(userType,null=True,blank=True)

class B2G(models.Model):#多对多数据结构模式创建

boy=models.ForeignKey("Boy")

girl=models.ForeignKey("Girl")

class Boy(models.Model):

name=models.CharField(max_length=32)

class Girl(models.Model):

name=models.CharField(max_length=32)
# f=models.ManyToManyField(Boy)


a:单表

b:一对多

c:多对多


    name=models.CharField(max_length=32,verbose_name="用户名",db_column="u")#显示的名字和更改的列名

help_text提示

error_message(错误的提示)

upload_to("目录")需要创建一个目录