0

標準の django コメント フレームワークを使用しています。

テンプレート:

<h2>Add comment</h2> {%  get_comment_form for post as form %} 
<form  action="{% comment_form_target %}" method="post" > {% csrf_token %}   
{{form.content_type}}{{form.object_pk}}{{form.timestamp}}{{form.security_hash}}
Comment:<br />
{{form.comment}}

<input type="hidden" name="next" value="{{ request.get_full_path }}#comment" /> 

<button class="btn btn-large btn-primary" type="submit">Post</button>

</form>

{{form.comment}}フィールドサイズを変更するにはどうすればよいですか? <p>orでラップしようとしまし<div>たが、うまくいきませんでした。どうも!

4

3 に答える 3

3

いくつかのオプションがあります:

1) django-widget-tweaksを使用できます。その場合、次のように記述{{form.comment|attr:"cols:10"|attr:"rows:10"}}します。

<textarea id="id_comment" rows="10" cols="10"></textarea>

2) textarea の id が になることもわかりますid_comment。したがって、css で幅を制御できます。

textarea#id_comment {width:100px;}
于 2013-03-01T13:19:18.600 に答える
2

このようなものを追加しました

#id_comment {
width: 95% !important; 
height: 200px !important; 
resize: none !important; 
} 

私のCSSファイルに。それは働いている!

于 2013-03-01T13:07:02.277 に答える
1

アプリを調べたところcontrib.comments、独自のコメント アプリを作成せずにウィジェットをカスタマイズする方法がわかりません。最も簡単な解決策は、通常の HTML テキスト入力またはテキストエリアを作成することです。name="comment" and id="id_comment"

于 2013-03-01T12:55:26.417 に答える