2011-10-22 20 views
0

當我嘗試發表評論在我的HTML,作者的電子郵件,而不是評論正在推出某種方式: asdas(2011年10月22日,下午2:38) marijus .merkevicius @ gmail.com不同的領域,然後預計被推出在HTML

這裏是我的模型:

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 %} 

回答

1

那是因爲你存儲在註釋字段中的電子郵件地址:

comment = cd["email"],