#28707: multidb admin uniqueness issue - No way to make the django admin perform
unique checks on non default db.
-------------------------------------+-------------------------------------
               Reporter:  coulix     |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  1.11
  layer (models, ORM)                |       Keywords:  multidb admin
               Severity:  Normal     |  uniqueness
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 In a multi-db configuration it seems that constraints such as model field
 **unique=True** does always target the **default** db in the Django admin.
 It ignores the **MultiDBModelAdmin** way as explained here
 https://docs.djangoproject.com/en/1.11/topics/db/multi-db/#exposing-
 multiple-databases-in-django-s-admin-interface.

 Digging a bit I see the **_perform_unique_checks** method here that does
 not seem to be able to take an other db connection than the default.

 
https://github.com/django/django/blob/fb02ebe889eee292144f9157ed4ddcdcc139eba9/django/db/models/base.py#L1005

 {{{
  qs = model_class._default_manager.filter(**lookup_kwargs)
 }}}

 For now I am going to use my own validator on save but either I am doing
 it wrong or there is a bug / doc update that needs attention.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28707>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.112827ae442584af15bb39f4d4da2630%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to