jschrewe / django-mongoadmin

Integrates mongodb into django's admin
http://www.schafproductions.com/projects/mongo-admin/
BSD 3-Clause "New" or "Revised" License
112 stars 38 forks source link

EmbeddedDocuments must be in ListFields #2

Closed jsocol closed 12 years ago

jsocol commented 12 years ago

MongoEngine trivially supports the following structure, but mongoadmin does not:

class Inner(EmbeddedDocument):
    val = StringField()

class Outer(Document):
    name = StringField()
    inner = EmbeddedDocumentField(Inner)

I'm working on a pull request but I wanted to get this on file in case you have any ideas.

jschrewe commented 12 years ago

The last time I used that it worked. I'll have a look at it tomorrow.

jschrewe commented 12 years ago

Yeah, you're right that doesn't work. I was never sure about how to represent that right in the admin. Now that I think about it for some more time: Adding an inline admin with exactly one form should be the way to go. That should actually be quite easy to handle. I'm not sure how far your pull request has come along. If it's not that far I'd look into it or I can wait.

jsocol commented 12 years ago

I didn't get very far. My goal was to show a single inline form, but the assumption that it's a list goes down pretty far, and I was trying to remove that assumption. Maybe the best option is to wrap the field in some kind of fake list in DocumentAdmin.get_inline_instances().

jschrewe commented 12 years ago

The last commit should fix this. Though I've just noticed it doesn't work if the embedded document is required.