-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ListField with ForeignKeys #10
Comments
LGTM. |
Right, but actually it works if you use model.pk when creating the list. 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.pk, model2.pk])
self.assertEqual(ReferenceList.objects.get().keys[0], model1.pk)
self.assertEqual(
Model.objects.get(pk=ReferenceList.objects.get().keys[0]),
model1) The following doesn't work with Mongo however: self.assertEqual(len(ReferenceList.objects.filter(keys=model1.pk)), 1) |
That's no good. Does it crash? If it does, what's the stacktrace? If it doesn't, what Mongo query is used and what does the |
wrwrwr
added a commit
that referenced
this issue
Feb 7, 2012
wrwrwr
added a commit
that referenced
this issue
Feb 20, 2012
…or/from_db), doing all that needs to be done for nonrel fields and database drivers that can only process values of standard Python types. Allows for a simplification of back-ends code, corrects a couple of problems with the current implementations partly fixing issue #10 and django-nonrel/mongodb-engine#47.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nearly works with Mongo (somewhat similar to issue 47 there), might be expressive in some cases.
The text was updated successfully, but these errors were encountered: