Created
October 9, 2012 14:28
-
-
Save johnschimmel/3859174 to your computer and use it in GitHub Desktop.
example model with mongoengine and wtforms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from mongoengine import * | |
from flask.ext.mongoengine.wtf import model_form | |
from datetime import datetime | |
class Comment(EmbeddedDocument): | |
name = StringField() | |
comment = StringField() | |
timestamp = DateTimeField(default=datetime.now()) | |
class Idea(Document): | |
creator = StringField(max_length=120, required=True, verbose_name="First name") | |
title = StringField(max_length=120, required=True) | |
slug = StringField() | |
idea = StringField(required=True, verbose_name="What is your idea?") | |
# Category is a list of Strings | |
categories = ListField(StringField(max_length=30)) | |
# Comments is a list of Document type 'Comments' defined above | |
comments = ListField( EmbeddedDocumentField(Comment) ) | |
# Timestamp will record the date and time idea was created. | |
timestamp = DateTimeField(default=datetime.now()) | |
# Create a Validation Form from the Idea model | |
IdeaForm = model_form(Idea) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment