django-nonrel/djangotoolbox — Issue #10: ListField with ForeignKeys
Author: wrwrwr
Created: 2012-01-23 14:13:42+00:00
State: open

Nearly works with Mongo (somewhat similar to issue 47 there), might be expressive in some cases.

```python
def test_list_with_foreignkeys(self):
class Model(models.Model):
pass
class ReferenceList(models.Model):
keys = ListField(models.ForeignKey(Model))
model1 = Model.objects.create()
model2 = Model.objects.create()
ReferenceList.objects.create(keys=[model1, model2])
self.assertEqual(
Model.objects.get(pk=ReferenceList.objects.all()[0].keys[0]),
model1)
```