Skip to content

Commit 4c9b0d2

Browse files
committed
Updates to the flask mongoengine tutorial
1 parent e628aa3 commit 4c9b0d2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

source/tutorial/write-a-tumblelog-application-with-flask-mongoengine.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ Install with the following commands:
8484
pip install flask
8585
pip install flask-script
8686
pip install WTForms
87-
pip install https://github.com/hmarr/mongoengine/tarball/dev
88-
pip install https://github.com/rozza/flask-mongoengine/tarball/master
87+
pip install mongoengine
88+
pip install flask_mongoengine
8989

9090
Continue with the tutorial to begin building the "tumblelog"
9191
application.
9292

9393
.. _WTForms: http://wtforms.simplecodes.com/docs/dev/
9494
.. _Flask-Script: http://pypi.python.org/pypi/Flask-Script
95-
.. _Flask-MongoEngine: http://github.com/rozza/flask-mongoengine
95+
.. _Flask-MongoEngine: http://github.com/MongoEngine/flask-mongoengine
9696

9797
Build a Blog to Get Started
9898
---------------------------
@@ -120,7 +120,7 @@ provides a development server and shell:
120120
import os, sys
121121
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
122122

123-
from flaskext.script import Manager, Server
123+
from flask.ext.script import Manager, Server
124124
from tumblelog import app
125125

126126
manager = Manager(app)
@@ -157,10 +157,11 @@ Install the Flask_ extension and add the configuration. Update
157157
.. code-block:: python
158158

159159
from flask import Flask
160-
from flaskext.mongoengine import MongoEngine
160+
from flask.ext.mongoengine import MongoEngine
161161

162162
app = Flask(__name__)
163163
app.config["MONGODB_DB"] = "my_tumble_log"
164+
app.config["SECRET_KEY"] = "KeepThisS3cr3t"
164165

165166
db = MongoEngine(app)
166167

@@ -203,6 +204,7 @@ In this application, you will define posts and comments, so that each
203204
return self.title
204205

205206
meta = {
207+
'allow_inheritance': True,
206208
'indexes': ['-created_at', 'slug'],
207209
'ordering': ['-created_at']
208210
}
@@ -442,7 +444,7 @@ and the :py:class:`DetailView` class to this file:
442444

443445
.. code-block:: python
444446

445-
from flaskext.mongoengine.wtf import model_form
447+
from flask.ext.mongoengine.wtf import model_form
446448

447449
...
448450

@@ -501,7 +503,7 @@ create comments. Create a macro for the forms in
501503
{% macro render(form) -%}
502504
<fieldset>
503505
{% for field in form %}
504-
{% if field.type == 'HiddenField' %}
506+
{% if field.type in ['CSRFTokenField', 'HiddenField'] %}
505507
{{ field() }}
506508
{% else %}
507509
<div class="clearfix {% if field.errors %}error{% endif %}">
@@ -619,7 +621,7 @@ following view is deliberately generic, to facilitate customization.
619621
from flask import Blueprint, request, redirect, render_template, url_for
620622
from flask.views import MethodView
621623

622-
from flaskext.mongoengine.wtf import model_form
624+
from flask.ext.mongoengine.wtf import model_form
623625

624626
from tumblelog.auth import requires_auth
625627
from tumblelog.models import Post, Comment
@@ -831,6 +833,7 @@ class and create new classes for the new post types. Update the
831833
return self.__class__.__name__
832834

833835
meta = {
836+
'allow_inheritance': True,
834837
'indexes': ['-created_at', 'slug'],
835838
'ordering': ['-created_at']
836839
}

0 commit comments

Comments
 (0)