-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learning Flask Framework
A model is the data representation of a table of data that we want to store in the database. These models have attributes called columns
that represent the data items in the data. So, if we were creating a Person model, we might have columns for storing the first and last name, date of birth, home address, hair color, and so on. Since we are interested in creating a model to represent blog entries, we will have columns for things like the title and body content.
Note that we don't say a People model or Entries model – models are singular even though they commonly represent many different objects.
With SQLAlchemy, creating a model is as easy as defining a class and specifying a number of attributes assigned to that class. Let's start with a very basic model for our blog entries. Create a new file named models.py in the blog project's app/ directory and enter the following code:
import datetime, re
from app import db
def slugify(s):
return...
Change the font size
Change margin width
Change background colour