[Fixed]-Uploading image in template

1👍

Add request.FILES in your views

form = CityForm(request.POST, request.FILES)

and make sure you have enctype="multipart/form-data" and method="post" in your template

<form method="post" enctype="multipart/form-data">{% csrf_token %}
</form>

https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.FILES

Leave a comment