When I try to put out comment in my html, author’s email instead of comment is being put out somehow:
asdas(Oct. 22, 2011, 2:38 p.m.)
marijus.merkevicius@gmail.com
Here’s my models :
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)
Here’s my view:
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))
And here’s my template:
{% for comment in comments %}
<p>{{ comment.name }}(<i>{{ comment.pub_date }}</i>)<br/>{{ comment.comment }}</p>
{% endfor %}
That’s because you store the email address in the comment field: