def add_note(): """Add a note.""" form = ArticleForm() if request.method == 'POST': if form.validate_on_submit(): # Get the right number - the article ID number = 1 notes = Note.all().order('-number') if notes.count() > 0: number = notes[0].number + 1 note = Note( number=number, title=form.title.data, content=form.content.data, tags=form.tags.data, ) note.save() return redirect(note.get_absolute_url()) action_url = url_for('add_note') return render_template('add_note.html', form=form, action_url=action_url)