#27188: Allow using unique=True with FileField
-------------------------------------+-------------------------------------
Reporter: Jon Ribbens | Owner: Michael
| Scott
Type: New feature | Status: closed
Component: File | Version: 1.10
uploads/storage |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sultan):
Why not implement this with the `Model.validate_unique()` method? It was
created precisely for this. It is already using resources for connecting
to the database and checking that there is no duplication.
I think that before `Model.validate_unique()` is called, we need first to
prepare the final `file.name` value by calling the
`FileFIeld.generate_filename()` method. The most appropriate place to do
this is in the `FileDescriptor.__set__` method, rather than in the
`FieldFile.save()` method, which I prefer, so that it always only accepts
the final filename.
--
Ticket URL: <https://code.djangoproject.com/ticket/27188#comment:9>
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/066.7fd0d23fec69f2ac449bfedea9b08f68%40djangoproject.com.