
django
weixin_43820008
这个作者很懒,什么都没留下…
展开
-
You called this URL via POST, but the URL doesn‘t end in a slash and you have APPEND_SLASH set. Djan
You called this URL via POST, but the URL doesn’t end in a slash andyou have APPEND_SLASH set. Django can’t redirect to the slash URLwhile maintaining POST data. Change your form to point to127.0.0.1:8000/polls/pl_yh2/ (note the trailing slash), or set.原创 2022-03-19 15:35:38 · 737 阅读 · 0 评论 -
django中group by 怎么用 一直报错NameError: name ‘Count‘ is not defined
今天需要在django上实现group by但是网上的例子在我的电脑上怎么都试不出来例子:sql语句select name,count(id) as counts from foo_personmodel group by name;django实现语句PersonModel.objects.values("name").annotate(counts=Count(id))虽然语句是对的但是一直报错NameError: name 'Count' is not defined然后才发现是少了原创 2022-03-15 15:13:06 · 3079 阅读 · 0 评论 -
CSRF验证失败. 请求被中断.
CSRF验证失败. 请求被中断.当出现这个bug的时候一般情况下是使用<form>并用post传递的原因只需要在<form>标签下一行加上{% csrf_token %}即可原创 2022-03-10 22:09:18 · 1519 阅读 · 0 评论 -
django——mysql数据库反映射数据模型到models
因为单纯使用models来定义表真是太麻烦了这篇主要是讲在mysql中建立一个表然后直接在models中生成代码step1:在mysql中创建表step2:在cmd中输入python manage.py inspectdb>polls/models.py其中polls为你创建的app名step3:点击models.py即生成完毕另附在models中写代码映射到MySQL中的方法step1:输入你要新建的表名称等class PollsStudentinfo1(models.Mod原创 2022-02-16 12:30:56 · 1166 阅读 · 1 评论 -
Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)
输入mysql -uroot -p然后输入密码即可原创 2022-02-15 21:27:05 · 1030 阅读 · 0 评论