1👍
According to the Django MongoDB Engine documentation, it suggests to use EmbeddedModel from djangotoolbox:
from djangotoolbox.fields import ListField, EmbeddedModelField
class Post(models.Model):
...
comments = ListField(EmbeddedModelField('Comment'))
class Comment(models.Model):
text = models.TextField()
Edit: Forgot the link: http://django-mongodb-engine.readthedocs.org/en/latest/topics/embedded-models.html
0👍
I actually just figured out what was wrong.
It is apparently impossible to declare the foreign key class type as a string when in a Listfield. Weird…
If it happens to you, just do the following change:
list = ListField(models.ForeignKey('AWUser'))
becomes:
list = ListField(models.ForeignKey(AWUser))
If anyone as a good explanation of what is going on, I’d love to hear it 🙂
- [Answer]-Invalid response of JSON data from Django QuerySet
- [Answer]-Get_absolute_url stopped working?
- [Answer]-Django turn based browser game – database design to handle separate time steps
- [Answer]-Django csrf in mobile apps
- [Answer]-Django correct applications distribution
Source:stackexchange.com