From ff749dfdf52e4b12e22283920be840fd55307eb1 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Mon, 16 Nov 2020 00:01:33 +1100 Subject: [PATCH] put ordering into Author object so fields render as surname before firstname --- author.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/author.py b/author.py index acf6e79..732d8c3 100644 --- a/author.py +++ b/author.py @@ -7,8 +7,8 @@ from __main__ import db, app, ma ################################################################################ class Author(db.Model): id = db.Column(db.Integer, unique=True, nullable=False, primary_key=True) - firstnames = db.Column(db.String(50), unique=False, nullable=False) surname = db.Column(db.String(30), unique=False, nullable=False) + firstnames = db.Column(db.String(50), unique=False, nullable=False) def __repr__(self): return "".format(self.id,self.firstnames, self.surname) @@ -17,7 +17,9 @@ class Author(db.Model): # Helper class that inherits a .dump() method to turn class Author into json / useful in jinja2 ################################################################################ class AuthorSchema(ma.SQLAlchemyAutoSchema): - class Meta: model = Author + class Meta: + model = Author + ordered = True ################################################################################ # Helper class that defines a form for author, used to make html
, with field validation (via wtforms)