#31774: validate_unique in Model class doesn't validate uniqueness for 
ImageField.
-------------------------------------+-------------------------------------
     Reporter:  Gaurav Ghildyal      |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |  worksforme
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Gaurav Ghildyal):

 The automatic random string is appended by the storage layer - in this
 case the default FileSystemStorage class.

 I was storing the filles on AWS S3 using the S3Storage from the https
 ://django-storages.readthedocs.io/en/latest/ library which doesn't do
 that, it just overwrites the file on the actual storage and returns the
 same name as set by the form, which the validate_unique function fails to
 catch but the database layer throws an exception due to name conflict.

 Maybe asserting the uniqueness should become a part of the storage layer
 instead of the model layer, but in that case the validate_unique function
 should exclude ImageField and FileFields from uniqueness validation and
 documentation should be updated to reflect this?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31774#comment:2>
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/067.21aaa8374778e6263b68fa6e1e999bbf%40djangoproject.com.

Reply via email to