I am testing for cleaned_data['content'].size > MAX_SIZE
in forms to validate the upload size.
When googling how to check the length for an upload in Django, I came across several places (links below) where people are using some format (seemingly based on powers of 2 somehow) to represent MBs in bytes.
I guess there must be a good reason.
Why use such a format ? And how do you calculate the values below? (taken from the linked SO question)
# 2.5MB - 2621440
# 5MB - 5242880
# 10MB - 10485760
# 20MB - 20971520
# 50MB - 5242880
# 100MB 104857600
# 250MB - 214958080
# 500MB - 429916160
Django File upload size limit
https://djangosnippets.org/snippets/1303/
https://django-filebrowser.readthedocs.org/en/3.5.2/settings.html