2👍
✅
Please update your edit view like this:- That line has to change like this-
form = ServerForm(request.POST or None, request.FILES or None, instance=server)
def server_update(request, pk, template_name='servers/server_form.html'):
server = get_object_or_404(Server, pk=pk)
form = ServerForm(request.POST or None, request.FILES or None, instance=server)
if form.is_valid():
edit = form.save(commit=False)
edit.save()
return redirect('server_list')
return render(request, template_name, {'form':form})
0👍
Have you tried sending the data manually as a dictionary instead?
form = Form({'charfield': model.charfield, 'imagefield': model.image})
This way you could try some other options. Presumably you need to send the actual file data, so you would end up sending: model.image.read() instead of just model.image
- [Answered ]-Django model A can has only one instance of model B
- [Answered ]-How Can I follow A Link to a specific post and scrape the data from the
- [Answered ]-AWS – DJANGO – Error in formatting: OperationalError: fe_sendauth: no password supplied
- [Answered ]-Django urls space gets added after main url
Source:stackexchange.com