I would be nice if support for composite primary keys would be implemented as a 
special case of general composite fields. There would be no need for new Meta 
options:

class Foo(Model):
    x = models.FloatField()
    y = models.FloatField()
    coords = models.CompositeField((x, y), db_index=True)
    a = models.ForeignKey(A)
    b = models.ForeignKey(B)
    pair = models.CompositeField((a, b), primary_key=True)

A CompositeField descriptor would then return a namedtuple of its values and 
would support queries:
    
    filter(coords__x=42)
    filter(coords=(1,2))

Adding the individual fields may be optional, e.g, 
CompositeField((FloatField(), FloatField()), db_index=True).

This has been proposed before: 
http://groups.google.com/group/django-developers/browse_thread/thread/32f861c8bd5366a5

__
Johannes

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to