/flask_template

Primary LanguagePythonMIT LicenseMIT

Welcome to Carease!

flask migrate: Add the following option to prevent errors def run_migrations_online(): context.configure(connection=connection, target_metadata=target_metadata, process_revision_directives=process_revision_directives, render_as_batch=True, ***** Add This Option ********

Like most Flask extensions, you need to create an instance right after the Flask application is created.

It is always best to move the application logic away from view functions and into models or other auxiliary classes or modules, because as you will see later in this chapter, that makes unit testing much easier.

The build for followers included 1. (models.py) create the database elements 2. (test.py) create tests 3. (routes.py) create the view functions 4. Add elements into the html

Something important related to processing of web forms. After I process the form data, I end the request by issuing a redirect to the home page even though this is the view function of the home page. It is a standard practice to respond to a POST request generated by a web form submission with a redirect. Called Post/Redirect/Get pattern

flask db migrate -m "some message" flask db upgrade ValueError: Constraint must have a name

-to fix this issue, do this to the version file; with op.batch_alter_table('measure', schema=None) as batch_op: batch_op.add_column(sa.Column('value', sa.String(), nullable=True)) # -comment out- batch_op.create_unique_constraint(None, ['name']) # the None refers to the object measure which is changed to measure.value # the second argument is the field name batch_op.create_unique_constraint('value', ['value']) # corrected version