#26352: models.E003 check incorrectly prevents duplicate ManyToMany through-self
that differ by through_fields
-------------------------------------+-------------------------------------
     Reporter:  Simon Willison       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.9
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Raymond Penners):

 * status:  closed => new
 * resolution:  wontfix =>


Comment:

 This ticket got closed because of a missing use case. For what it is
 worth, our "real world use case" is the following:

 {{{#!python
 class ShippingMethod(models.Model):
     ....
     to_countries = models.ManyToManyField(
         Country, through='carriers.ShippingMethodPrice',
         through_fields=('method', 'to_country'))

     # This is the 2nd ManyToManyField causing E003:
     #
     # from_countries = models.ManyToManyField(
     #     Country, through='carriers.ShippingMethodPrice',
     #     through_fields=('method', 'from_country'), related_name='+')


 class ShippingMethodPrice(models.Model):
     ...
     method = models.ForeignKey(
         ShippingMethod,
         related_name='prices'
     )
     to_country = models.ForeignKey(Country)
     from_country = models.ForeignKey(Country, related_name='+')
     price = models.DecimalField()

 }}}

 So, basically, we have list of shipping methods, and each shipping method
 has a price list, containing a specific price per from/to-country
 combination.
 Given a method, `method.from_countries` should represent the set of all
 countries that are occur in the price list as a from-country.

 I do not think the workaround suggested in
 https://code.djangoproject.com/ticket/26352#comment:2 works for us, as our
 case involves 3 models.

 The hack to disable E003 seems to work, though a real fix (or suggestions
 how to receive the same result otherwise) would be appreciated.

--
Ticket URL: <https://code.djangoproject.com/ticket/26352#comment:6>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d6c42bf22b180b90bb985db5393f6ffe%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to