Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Hi, Thanks for reverting back. It's a update profile page, and using FormData, I am sending profile picture along with other information using .append() method. But if for the next time, I don't want to update profile picture but just the text in the profile then I get this error django.utils.datastructures.MultiValueDictKeyError: 'file' Is there any way I can make it work even if the fd['file'] is Null. Commented Dec 4, 2021 at 13:27
  • You should check if the key exists in request.FILES before accessing it via if 'file' in request.FILES or you can use .get() which will default to None if it doesn't exist. Commented Dec 4, 2021 at 16:06
  • Thanks. Done. I want to confirm is it a safe way to do it ? Or can you provide me some of your worthy suggestions to improve it ? Commented Dec 11, 2021 at 6:11
  • What do you mean by "safe way to do it"? Commented Dec 11, 2021 at 15:00