Why does Django throw a DATA_UPLOAD_MAX_MEMORY_SIZE error even when uploading files (not setting FILE_UPLOAD_MAX_MEMORY_SIZE)

I’m encountering an issue where Django raises a DATA_UPLOAD_MAX_MEMORY_SIZE error during file uploads, even though I haven’t explicitly set FILE_UPLOAD_MAX_MEMORY_SIZE. Here’s my setup:

  • No explicit FILE_UPLOAD_MAX_MEMORY_SIZE in settings.
  • Error occurs in Sentry but references DATA_UPLOAD_MAX_MEMORY_SIZE.

Questions:

  1. Why does Django check DATA_UPLOAD_MAX_MEMORY_SIZE for file uploads instead of FILE_UPLOAD_MAX_MEMORY_SIZE?
  2. Are there differences in behavior between Django 1.11 and 4.0?
  3. Should both settings always be configured together?

Any insights would be appreciated!

DATA_UPLOAD_MAX_MEMORY_SIZE and FILE_UPLOAD_MAX_MEMORY_SIZE are two different settings that do two different things. See the docs for the full explanation.