when i tried to upload images as files which shows AttributeError at /add_property 'NoneType' object has no attribute 'name'
def add_property(request):
if request.method == 'POST':
pro_typ = request.POST.get('pro_typ')
pro_tit = request.POST.get('pro_tit')
pro_for = request.POST.get('pro_for')
rt = Property.objects.filter(Property_reg=request.session['logg'])
for u in rt:
if u.Property_type == pro_typ and u.Property_title == pro_tit and u.property_sell_rent == pro_for:
messages.success(request, 'Property already exists')
return redirect('pro_sell')
c_b1 = request.POST.get('c_b1')
n_c1 = request.POST.get('n_c1')
c_f1 = request.POST.get('c_f1')
photo = request.FILES.get('photo')
fs = FileSystemStorage()
fs.save(photo.name, photo)
pk = Registration.objects.get(id=request.session['logg'])
cdt = Property()
cdt.Property_type = pro_typ
cdt.Property_title = pro_tit
cdt.Property_brief = c_b1
cdt.Num_of_rooms = n_c1
cdt.Price = c_f1
cdt.Property_sell_rent = pro_for
cdt.Property_reg = pk
cdt.save()
messages.success(request, 'Added property successfully')
return redirect('pro_sell')
return render(request, 'add_property.html')
<td>
<label for="photo"><b style="color:yellow;">Photo</b></label>
</td>
<td>
<input type="file" size="10" name="photo" multiple>
</td>
</tr>
and it shows the error
AttributeError at /add_property 'NoneType' object has no attribute 'name'
Local vars C:\Users\VYSHNAVAM\Desktop\REALESTATE\landholdings\real\views.py, line 223, in add_property fs.save(photo.name, photo)
solution for this. how can we callback multiple files