当我试图在我的HTML中发表评论时,作者的电子邮件而不是评论正以某种方式被推出: asdas(2011年10月22日,下午2:38) marijus.merkevicius@gmail.com
这是我的模特:
class Comment(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
pub_date = models.DateTimeField(auto_now_add=True)
comment = models.TextField()
entry = models.ForeignKey(Entry)
以下是我的观点:
def detail(request, blog_slug):
entry = get_object_or_404(Entry, slug = blog_slug)
if request.method == "POST":
form = CommentForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
comment = Comment(name = cd["name"], email = cd["email"],
comment = cd["email"],
entry = entry)
comment.save()
return redirect("blog.views.detail", blog_slug = blog_slug)
else:
form = CommentForm()
comments = Comment.objects.filter(entry = entry)
return render_to_response("detail.html", {"entry" : entry,
"comments" : comments,
"form" : form},
context_instance = RequestContext(request))
这是我的模板:
{% for comment in comments %}
<p>{{ comment.name }}(<i>{{ comment.pub_date }}</i>)<br/>{{ comment.comment }}</p>
{% endfor %}
答案 0 :(得分:1)
那是因为您将电子邮件地址存储在评论栏中:
comment = cd["email"],