ForeignKey should have a constraint
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Most of the time when you have a ForeignKey you only want it to access some of the table's data, so I propose a constrained be implemented (like the one for the admin site). The constraint would be specified in the model and would be a QuerySet object that filters objects from the table and returns the suitable ones as FK choices.
This would also work in forms, limiting their choices.
Change History (6)
comment:1 Changed 9 years ago by
|Patch needs improvement:||unset|