Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed multi file upload in django forms
    primarykey
    data
    text
    <p>I have given my code below. It is having a image field. I'm using django forms and custom templates to fill and store this information. And I want to allow users to upload 0 to 10 images for each book as per their wish. So how can I achieve it. My requirements are as follows:</p> <ol> <li>Minimum - 0 file, Maximum - 10 files</li> <li>Allowed file types - *.jpg, *.jpeg, *.gif, *.png</li> <li>Either it can be a browse file field or a button which will call a window to select multiple files.</li> <li>I want to save and retrieve these images and edit them in future.</li> </ol> <p><strong>models.py</strong></p> <pre><code>class Book(models.Model): title = models.CharField(max_length = 200) author = models.CharField(max_length = 200) cost = models.IntegerField() description = models.TextField() image = models.ImageField(upload_to = 'images/books/', null = True, blank = True) </code></pre> <p><strong>forms.py</strong></p> <pre><code>class BookForm(forms.ModelForm): class Meta: model = Book widgets = { 'location' : forms.TextInput(attrs={'placeholder': 'Location'}), 'title' : forms.TextInput(attrs={'placeholder': 'Title'}), 'author' : forms.TextInput(attrs={'placeholder': 'Author'}), 'cost' : forms.TextInput(attrs={'placeholder': 'Price'}), 'description': forms.Textarea(attrs={'placeholder': 'Description'}), } </code></pre> <p>Before asking this question, I tried <a href="https://github.com/garmoncheg/django_multiuploader/" rel="nofollow" title="Garmoncheg django_multiuploader">Garmoncheg django_multiuploader</a> and <a href="http://scompt.com/blog/archives/2007/11/03/multiple-file-uploads-in-django" rel="nofollow">Scompt multifile widget</a>. But none of them helped me. I'm working on this task for the past two days, but couldn't get it working. So Please suggest me a way of completing this task successfully.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload