그래서 django.contrib.comments를 사용하고 있습니다. 나는 그것을 설치했지만 다루기 힘든 기본 주석 폼보다는 텍스트 영역과 제출 버튼 만 보여주는 사용자 정의 폼 템플릿을 사용하고 싶습니다.django-comments 사용자 정의
이 근거는 사용자가 이미 인증 된 영역 만 볼 수 있으며 양식을 간단하게 유지하고 사용자 이름 등을 자동으로 가져오고 싶습니다.
사용자 지정 양식을 구현했지만 제출하려고 할 때 오류가 발생합니다.
{% load comments %}
{% render_comment_form for entry %}
그리고 여기 /templates/comments/form.html 내 HTML입니다 : 여기
은 (항목이보기에서 전달 된 객체이다) 내가 코멘트 양식이있는 페이지 내 템플릿에있는 내용은 다음과 같습니다{% if user.is_authenticated %}
<p>Submit a comment:</p>
<form action="/comments/post/" method="post">
<textarea name="comment" id="id_comment" rows="2" style="width: 90%;"></textarea>
<input type="hidden" name="options" value="{{ options }}" />
<input type="hidden" name="target" value="{{ target }}" />
<input type="hidden" name="gonzo" value="{{ hash }}" />
<input type="hidden" name="next" value="{{ entry.get_absolute_url }}" />
<span style="float:right;"><input type="submit" name="post" value="Add"></span>
</form>
{% else %}
<p>Please <a href="/login/">log in</a> to post a comment.</p>
{% endif %}
그것은 처음에는 괜찮 렌더링,하지만 난 코멘트 양식을 제출하려고 할 때, 나는 다음과 같은 장고 오류 얻을 :
Comment post not allowed (400)
Why: Missing content_type or object_pk field.
,691을
아무도 도와 줄 수 있습니까?