#33880: Ambigous error message regarding "FilePathFields must have either
'allow_files' or 'allow_folders' set to True."
-------------------------------------+-------------------------------------
Reporter: Willem | Owner: nobody
Van Onsem |
Type: | Status: new
Uncategorized |
Component: Database | Version: 4.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Django's FilePathField
(https://docs.djangoproject.com/en/dev/ref/models/fields/#filepathfield)
specifies for the allow_files and allow_folders:
> Optional. Either `True` or `False`. Default is `True`. Specifies whether
files in the specified location should be included. Either this or
`allow_folders` must be `True`.
(analogue for allow_folders)
This seems to hint that one should set `allow_files` to True or
`allow_folders` to `True`; but not both at the same time.
In the corresponding code, it seems to say:
{{{
def _check_allowing_files_or_folders(self, **kwargs):
if not self.allow_files and not self.allow_folders:
return [
checks.Error(
"FilePathFields must have either 'allow_files' or
'allow_folders' "
"set to True.",
obj=self,
id="fields.E140",
)
]
return []
}}}
The code block thus checks that both parameters are not false (at the same
time).
It might be better to say "`allow_files` or `allow_folders` should be set
to True", since the either might hint that this is an exclusive or (based
on this post https://english.stackexchange.com/questions/13889/does-
either-a-or-b-preclude-both-a-and-b ).
This should then be both updated for the documentation, and for the error
codes I think.
--
Ticket URL: <https://code.djangoproject.com/ticket/33880>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701825537b787-67d06f8a-eabb-41fd-a23d-e41042485bd2-000000%40eu-central-1.amazonses.com.