1👍
In Django Templates, if you are trying to render a form that has a FileField. You must pass replace
<form method="post" action="">
with
<form method="POST" enctype="multipart/form-data">
https://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form
0👍
I’m afraid I don’t really understand your question, so apologies if this doesn’t help..
If your list is arbitary (as it looks from your question), then you could use django’s built in forloop counter to construct your file names –
{% for form in formset %}
{{ form }}
<input type="text" name="file_name" value="{% forloop.counter %}.png">
{% endfor %}
Alternatively have a look at python’s zip function. You could use it to build an object that includes both the names and the forms and pass that to your template.
- [Answer]-How to add custom data to Django MPTT model for recursetree template tag
- [Answer]-How to get arbitrary number of django apps running on same domain, sharing User database, but with different (and isolated) app models?
- [Answer]-Django queryset filter model attribute against other model attribute
- [Answer]-Using Django ORM to get a related model in a method
Source:stackexchange.com