Я новичок в Джанго. Я пытаюсь построить представление на основе класса, чтобы создать объект.
Имя формы по умолчанию в шаблоне — form, и я хочу изменить его на "ajoutersource"
, но не могу понять, как это сделать.
views.py
class ajoutSource(CreateView):
model = Source
template_name = "pmd/ajouterSource.html"
form_class = AjouterSourceForm
success_url = reverse_lazy(ListerSources)
ajouterSource.html
{% for field in ajoutersource %}
<div class="row">
{% if field.errors %}
<div class="error">{{ field.errors }}</div>
{% endif %}
<div class="label">{{ field.label }}</div>
<div class="field">{{ field }}</div>
</div>
{% endfor %}