#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
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * type:  Uncategorized => New feature
 * resolution:   => worksforme


Comment:

 I'm afraid I can't reproduce this with the given info.

 > **Actual Result**: An error page with a stacktrace (running with
 DEBUG=True) throwing an IntegrityError.

 I don't see that.

 Rather, uploaded files have a random string appended in order to create a
 unique name.


 {{{
 db.sqlite3> SELECT * from reproduce_validateunique;
 +----+---------------------------------------------------------+
 | id | logo                                                    |
 +----+---------------------------------------------------------+
 | 1  | logos/2020-03-19-View-from-inside-my-laptop.jpg         |
 | 2  | logos/2020-03-19-View-from-inside-my-laptop_xB8SLzj.jpg |
 | 3  | logos/2020-03-19-View-from-inside-my-laptop_YeNU9Rp.jpg |
 +----+---------------------------------------------------------+
 3 rows in set
 Time: 0.016s
 }}}

 (See `Storage.get_alternative_name()`)

 Can you adjust the uploaded sample project to demonstrate this issue?

 Possibly, there's a New Feature here. Originally `unique` was not
 supported for `FileField`. Support was added in 1.11, for #27188,
 supporting uniqueness of the `name` attribute.
 Maybe additional work is needed to push that out to the form layer (but
 pending the reproduce...)

 Checking the image contents is not (won't be) supported:

 > I think by definition ImageFields are unique; even if you upload the
 same image twice you'll still end up with two unique files.

 Jacob on #1898.

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

Reply via email to