Skip to content
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

Fields order for mongoengine is broken #89

Open
rochacbruno opened this issue Jul 20, 2013 · 7 comments
Open

Fields order for mongoengine is broken #89

rochacbruno opened this issue Jul 20, 2013 · 7 comments

Comments

@rochacbruno
Copy link
Contributor

Hi, it was working a week ago but now is broken.

I defined: https://github.com/rochacbruno/quokka/blob/master/quokka/modules/posts/admin.py#L35

fields_order = ['title', 'slug', 'channel', 'channels', 'summary',
                    'body', 'published', 'comments']

And admin rendered in the model defined order.

content post quokka admin

@iurisilvio
Copy link
Contributor

The fields_order parameter was removed, use fields instead.

@rochacbruno
Copy link
Contributor Author

I changed it to fields

fields = ['title', 'slug', 'channel', 'channels', 'summary',
                    'body', 'published', 'comments']

But now I got an error.

fields_jinja_error

@rochacbruno
Copy link
Contributor Author

I've found the problem.

When I define

    fields = ['title', 'slug', 'channel', 'channels', 'summary', 'body', 'published']

It works well.

But, if I include the EmbeddedDocumment it faills and raises that error.

    fields = ['title', 'slug', 'channel', 'channels', 'summary', 'body', 'published',
                 'comments']

In the above case I included comments in the list field.

class Comment(db.EmbeddedDocument, Publishable):
    body = db.StringField(verbose_name="Comment", required=True)
    author = db.StringField(verbose_name="Name", max_length=255, required=True)
    published = db.BooleanField(default=True)

    def __unicode__(self):
        return "{}-{}...".format(self.author, self.body[:10])

    meta = {
        'indexes': ['-created_at'],
        'ordering': ['-created_at']
    }

#And int he Post class

comments = db.ListField(db.EmbeddedDocumentField(Comment))

The problem, I guess is that it is looking for all the defined fields in the embedded document itself.

So there is a problem when using EmbeddedDocuments and fields argument.

@ghost
Copy link

ghost commented Jul 24, 2013

@rochacbruno Can you tell me which Rich Text Editor you used in 'Edit Post' page ?

@rochacbruno
Copy link
Contributor Author

@ghost
Copy link

ghost commented Jul 24, 2013

THX !

@mvdwaeter
Copy link

I have this issue too. Searched for the answer, found this post, but no answer. What's the fix? Because I want to order the fields AND include the EmbeddedDocument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants