0
我需要你這樣的問題的幫助:Django的 - 當時上傳多張圖像
這是我的models.py:
class Location(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
name = models.CharField(max_length=100, verbose_name="Локация", default=u'')
photos = models.ImageField(upload_to='photos', null=True)
這是我forms.py:
class LocationForm(forms.ModelForm):
class Meta:
model = Location
fields = ['name', 'photos']
這是我的views.py:
class AddLocationPageView(FormView):
template_name = 'add_location.html'
form_class = LocationForm
def form_valid(self, form):
form.save()
return super(AddLocationPageView, self).form_valid(form)
I需要有可能在當時上傳幾張照片。 我該怎麼做? 謝謝!
您需要了解[formsets](https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/#django.forms.models.BaseModelFormSet) –