Python中文
首页
教程
问答
标签
搜索
登录
注册
“question_text”是此函数的无效关键字参数
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我试图遵循Polls教程,包括来自项目的<code>urls.py</code>,以及Polls目录中的<code>models.py</code>。在</p> <pre><code>q = Question(question_text="some text", pub_date=timezone.now)) </code></pre> <p>导致以下错误:</p> ^{pr2}$ <p><strong>我的网站/网址.py</strong></p> <pre><code>from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^polls/', include('polls.urls')), url(r'^admin/', admin.site.urls), ] </code></pre> <p><strong>投票/模型.py</strong></p> <pre><code>import datetime from django.db import models from django.utils import timezone # Create your models here. class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question_text def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) def __str__(self): return self.choice_text </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我认为在学习教程的过程中,您已经做了很多代码更改,而这些并没有反映在sql数据库中。在</p> <p>所以,在做以上步骤之前,请遵循下面的步骤。在</p> <pre><code>python manage.py migrate python manage.py makemigrations polls python manage.py migrate </code></pre> <p>现在就这么做</p> ^{pr2}$
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
jupyter运行一个旧的pytorch版本
3 回答
Jupyter运行不同版本的卸载库?
10 回答
Jupyter运行指定的键盘快捷键
7 回答
Jupyter通过.local文件“逃逸”virtualenv。我该如何缓解这种情况?
5 回答
Jupyter重新加载自定义样式
6 回答
Jupyter错误:“没有名为Jupyter_core.paths的模块”
5 回答
jupyter错误:无法在随机林中将决策树视为png
1 回答
Jupyter错误'内核似乎已经死亡,它将自动重新启动'为一个给定的代码块
1 回答
Jupyter错误地用阿拉伯语和字母数字元素显示Python列表
1 回答
Jupyter隐藏数据帧索引,但保留原始样式
2 回答
Jupyter集线器:启动器中出现致命错误。。。系统找不到指定的文件
3 回答
Jupyther中相同值的相同哈希,但导出到Bigquery时不相同
6 回答
Jupy上Python的读/写访问问题
8 回答
jupy上没有模块cv
2 回答
Jupy上的排序错误
7 回答
Jupy中bqplot图形的紧凑布局
9 回答
Jupy中matplotlib plot的连续更新
8 回答
Jupy中Numpy函数的文档
10 回答
Jupy中Pandas的自动完成问题
3 回答
jupy中Qt后端的Matplotlib动画
2 回答