对于带有基数为10的int()的无效文字:'revision.user.id'
user_profile = articleread.objects.filter(user_id=request.POST.get("name"), article_id=str(request.POST.get("article"))).order_by('-id')[0]
也是错误
user_profile = articleread.objects.filter(user_id=int(request.POST.get("name")), article_id=str(request.POST.get("article"))).order_by('-id')[0]
<input name="percent" id="percent" size="4" type="text" form="my_form" />
<input name="name" id="name" type="hidden" value=revision.user.id form="my_form" />
<input name="article" id="article" type="hidden" value=article.id form="my_form" /></td>
<input type="submit" value="Submit"/ form="my_form"></td>
在模型db中,两个字段都是外键:
db.create_table(u'wiki_articleread', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('current_revision', self.gf('django.db.models.fields.related.OneToOneField')(blank=True, related_name=u'current_set', unique=True, null=True, to=orm['wiki.ArticleRevision'])),
('readed', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('last', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name=u'user_articles', null=True, on_delete=models.SET_NULL, to=orm['auth.User'])),
('paid', self.gf('django.db.models.fields.BooleanField')(default=False)),
('read', self.gf('django.db.models.fields.BooleanField')(default=True)),
('article', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['wiki.Article'])),
('percent', self.gf('django.db.models.fields.FloatField')(default='0')),
))
答案 0 :(得分:1)
在模板中包含变量时,您错过了大括号。例如,而不是
<input name="name" id="name" type="hidden" value=revision.user.id form="my_form" />
你应该
<input name="name" id="name" type="hidden" value={{ revision.user.id }} form="my_form" />
您可能想要使用Django forms进行探索。它们有几个有用的功能,包括自动生成html。