Django得到错误403

时间:2018-03-18 17:35:25

标签: python django

我正在处理多文件上传。一切正常,但有一个问题。文件正在移动到我想要的目录,但是当我尝试显示它们时,我收到此错误:

Forbidden
You don't have permission to access /media/taka-se/image026.jpg on this server.

这是views.py:

def post(self, request):
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            cd = form.cleaned_data
            gallery = cd['gallery']
            for image in cd['image']:
                Photo.objects.create(gallery=gallery, image=image)
            return redirect(reverse('account:gallery', kwargs={'postid': gallery.pk}))

这是forms.py:

class PhotoForm(forms.ModelForm):
    image = MultiImageField(
        min_num=1,
        max_num=25,
        max_file_size=429916160,
    )
    class Meta:
        model = Photo
        fields = ('gallery',)

0 个答案:

没有答案