2011-03-04 4 views
1

누군가 내가 뭘 잘못보고있는 걸까요? 내가 뭘 놓치고 있니?장고 - 덧글 양식을 렌더링 할 수 없습니다

# works 
{% get_comment_count for app.somemodel object_pk as comment_count %} 
{% get_comment_count for model as comment_count %} 

# Throws error: "Caught AttributeError while rendering: 'str' object has no attribute '_meta'" 
{% render_comment_list for app.somemodel %} 
{% render_comment_form for app.somemodel %} 

# Gives an empty form and empty list 
{% render_comment_list for model %} 
{% render_comment_form for model %} 

보기 :

# view.py 
from app.models import SomeModel 

def some_view(request): 

    return render_to_response("app/some_template.html", {'model': SomeModel}) 

답변

1

나는 코멘트 프레임 워크를 사용한 적이 있지만, 내가 가서거야와 모델을 전달하는 것이 좋습니다 예를 - 당신은 코멘트를 렌더링 할 수있는 방법 형식 또는 모델 목록 클래스?

주석은 모델과 ID에 대한 일반적인 관계가 있습니다. 모델 클래스에는 주석을 달 수 없습니다.

http://docs.djangoproject.com/en/dev/ref/contrib/comments/#displaying-the-comment-post-form

def some_view(request): 
    # pass in an instance, not a class, if you want to render a comment form 
    return render_to_response("app/some_template.html", {'model': SomeModel.objects.latest('id')}) 
관련 문제