1
を使用してジャンゴでgeneric.edit.CreateViewフォームをスタイリング:は、私は私のDjangoのアプリで次のビューを持っているブートストラップ
class TodoCreateView(generic.edit.CreateView):
model = Todo
fields = ['todo_name','todo_description']
template_name = 'list/todo-create.html'
success_url = reverse_lazy('list:index')
def form_valid(self, form):
form.instance.owner = self.request.user
form.instance.created_date = datetime.now()
return super(EntryCreateView, self).form_valid(form)
このビューには、次のテンプレートに対応:
明らか{% extends 'list/base.html' %}
{# Load the tag library #}
{% load bootstrap3 %}
{# Load CSS and JavaScript #}
{% bootstrap_css %}
{# Display django.contrib.messages as Bootstrap alerts #}
{% bootstrap_messages %}
{% block content %}
<h1>Todo:</h1>
<div>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save" />
</form>
{% endblock %}
、Djangoにビューに表示されているフィールドに基づいてフォームを作成し、出力します。しかし、CSSを使用してフォームフィールドをスタイルするチャンスはありません。どうやってやるの?
に、私が作成したDjangoのフォームのスタイルを設定することが可能であることを設定されていますか? – MadPhysicist
@MadPhysicist - リンクされた質問を見る – Sayse