Skip to content

Latest commit

 

History

History
23 lines (12 loc) · 1.43 KB

flask.md

File metadata and controls

23 lines (12 loc) · 1.43 KB

Random notes on Flask

When you are enlightened, write it down.

  • UserMixin doesn't have a query function; this is because the load_user() function was not returning a user, rather an instance of the user class with only the id populated.

Why use UserMixin?

UserMixin provides default implementations for the methods that Flask-Login expects user objects to have.

declarative_base() is a factory function that constructs a base class for declarative class definitions (which is assigned to Base variable in your example). The one you created in user.py is associated with User model.

From the docs:

Construct a base class for declarative class definitions.

The new base class will be given a metaclass that produces appropriate Table objects and makes the appropriate mapper() calls based on the information provided declaratively in the class and any subclasses of the class.

Do I need to run Base.metadata.create_all() each time?

A lot of examples for starting Flask have you use an interactive db session to start the database. But shouldn't this be something that is done programmatically?