django.utils.datastructures.MultiValueDictKeyError
2018-10-16 18:00
841 查看
django.utils.datastructures.MultiValueDictKeyError: 'a'
源代码如下
print(request.GET['a'])
其实就是在 request.Post/Get 时,提取的 Key 不存在导致的
QueryDict.getitem(key)¶
Returns the value for the given key. If the key has more than one value, it returns the last value. Raises django.utils.datastructures.MultiValueDictKeyError if the key does not exist. (This is a subclass of Python’s standard KeyError, so you can stick to catching KeyError.)
解决办法:
1.使用QueryDict.get()方法 2.先判断Key是否存在,然后获取
相关文章推荐
- Django 上传文件出现 multivaluedictkeyerror错误
- django.db.utils.IntegrityError:(1215, canot add foreign key constraint)
- 解决django.db.utils.DataError: (1406, "Data too long for column 'gender' at row 1")
- django.db.utils.OperationalError: table has more than one primary key
- django.db.utils.IntegrityError:(1215, canot add foreign key constraint)
- django.db.utils.OperationalError: no such table: auth_user
- django.db.utils.OperationalError: (1049, "Unknown database "test_django_mysql")的解决办法
- Magento Mysql import data - error - foreign key constraint failed
- django.db.utils.OperationalError: (1142, "REFERENCES command denied to user
- django.db.utils.ProgrammingError: (1146, u“Table‘’ doesn’t exist”)问题的解决
- 为什么django+mongo在windows上session能够获取到,同样的程序在linux上就会报session的变量错误,keyerror?
- django.db.utils.OperationalError: (1193, "Unknown system variable 'storage_engine'")
- django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'127.0.0.1' (using password:
- centos7解决django.db.utils.OperationalError: FATAL: Peer authentication failed for user "postgres"
- phpcms中,有时候写成{loop $data $key $val} ,有时候写成{loop $data $r}有什么区别呢?
- django.db.utils.ProgrammingError: (1146, "Table 'test_b.products_category' doesn't exist")
- django.db.utils.OperationalError: 1050解决方案
- django.db.utils.OperationalError: (1193, "Unknown system variable 'storage_engine'")
- django.db.utils.OperationalError: (1193, "Unknown system variable 'storage_engine'")
- django.db.utils.OperationalError: (1050, "Table 'devtypeinfo' already exists