My problem is that in the templates and in the CMD I return None instead of the images.
The views:
class AddProductImages(TemplateView):
template_name = "addimages.html"
def post(self, *args, **kwargs):
try:
images = self.request.FILES.getlist('images')
product = Product.objcts.get(id = self.kwargs['pk'])
for image in images:
product_images = Images.objcts.create(
product = product,
images = image
)
return redirect('index')
except Exception as e:
print(e)
The urls:
path('addimages/<int:pk>/', AddProductImages.as_view(), name="addimages"),
The templates:
<div class="container my-5">
<br />
<h1>ADD IMAGE</h1>
<br />
<hr />
<form action="" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="images" id="" class="form-control" multiple>
<br>
<button type="submit" class="btn btn-sm btn-primary my-3">Submit</button>
</form>
</div>
The results:
ValueError: The view photo.views.AddProductImages didn't return an HttpResponse object. It returned None instead. [31/Aug/2022 22:08:11] "POST /addimages/1/ HTTP/1.1" 500 65400
So, could someone check this please? Thanks!