#34237: FileField does not take upload_to into account when setting unique=True
-------------------------------------+-------------------------------------
Reporter: 0x4A-0x41-0x4B | Owner: nobody
Type: Bug | Status: closed
Component: File | Version: 4.1
uploads/storage |
Severity: Normal | Resolution: invalid
Keywords: FileField, Unique, | Triage Stage:
Storage, Upload | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* status: new => closed
* resolution: => invalid
Comment:
> Well, what's the point of upload_to then? Why would i ever use the
FileField's upload_to, if i can use the storage's generate_filename
method?
If you prefer to write and use a custom storage, please do. The
`upload_to` option is intended for most of users who would like to change
only the directory, not other storage mechanisms.
> This puts up a barrier for anyone trying to enforce a purely unique set
of file entries. The documentation for this is, if nothing else,
misleading:
> > This attribute provides a way of setting the upload directory and file
name ...
[https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.FileField.upload_to
Source]
> As its clearly NOT used to set the filename if the storage can (and
will) completely disregard it.
Built-in storage uses `upload_to`. I'm not sure what you're proposing, do
you want to document that 3rd-party storages can ignore `upload_to`? TBH,
they can do almost anything, that's how custom implementation works, I see
no point in documenting this. Feel-free to propose a docs clarification,
however I'm skeptical.
For me this ticket is still "invalid".
--
Ticket URL: <https://code.djangoproject.com/ticket/34237#comment:4>
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/0107018594d68a1a-563c5c8b-300d-4b91-81d2-764e77b6b65a-000000%40eu-central-1.amazonses.com.