标签:文件 获取数据 har idt formdata width alt view ima
MTV模型(django):
M:模型层(models.py)
T:templates
V:views
MVC模型:
M:模型层(models.py)
V:视图层(views.py)
C:控制器(Controller) urls.py
本质:django的MTV也是MVC
# 1、第一种django的orm自动创建 class Book(models.Model): name = models.CharField(max_length=32) authors = models.ManyToManyField(to=‘Author‘) class Author(models.Model): name = models.CharField(max_length=32) # 2、第二种纯手动创建第三张表 class Book(models.Model): name = models.CharField(max_length=32) class Author(models.Model): name = models.CharField(max_length=32) class Book2Author(models.Model): book = models.ForeignKey(to=‘Book‘) author = models.ForeignKey(to=‘Author‘) info = models.CharField(max_length=32) # 3、第三种半自动创建第三张表 class Book(models.Model): name = models.CharField(max_length=32) authors = models.ManyToManyField(to=‘Author‘, through=‘Book2Author‘, through_fields=(‘book‘, ‘author‘)) class Author(models.Model): name = models.CharField(max_length=3) book = models.ManyToManyField(to=‘Book‘, through=‘Book2Author‘, through_fields=(‘author‘, ‘book‘)) class Book2Author(models.Model): book = models.ForeignKey(to=‘Book‘) author = models.ForeignKey(to=‘Author‘) info = models.CharField(max_length=32)
对应的数据格式:name=jason&password=123
后端获取数据:request.POST
ps:django会将urlencoded编码的数据解析自动放到request.POST
form表单传输文件的编码格式
后端获取文件格式数据:request.FILES
后端获取普通键值对数据:request.POST
标签:文件 获取数据 har idt formdata width alt view ima
原文地址:https://www.cnblogs.com/zhangguosheng1121/p/11024484.html