#35956: Add composite foreign keys
-------------------------------------+-------------------------------------
     Reporter:  Csirmaz Bendegúz     |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):

 Replying to [ticket:35956 Csirmaz Bendegúz]:
 > My proposal is to add 2 parameters to `ForeignKey`: `from_fields` and
 `to_fields`.

 Do we need these parameters? `CompositePrimaryKey` is always a primary key
 so its fields should be detected automatically, IMO, the following example
 should work:
 {{{#!python
 class Release(models.Model):
     pk = models.CompositePrimaryKey("version", "name")
     version = models.IntegerField()
     name = models.CharField(max_length=20)


 class RefRelease(models.Model):
     release = models.ForeignKey("Release", models.CASCADE)
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35956#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 visit 
https://groups.google.com/d/msgid/django-updates/01070193ef480874-83b825e5-594c-46d0-91e6-df533f0176c9-000000%40eu-central-1.amazonses.com.

Reply via email to