Answer the question
In order to leave comments, you need to log in
Django - load multiple photos at once?
Good afternoon!
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)
Answer the question
In order to leave comments, you need to log in
You make a separate model for photos and connect it to location via m2m field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question