Skip to content
Snippets Groups Projects
Forked from Bo-Chun Chen / get_start_flask
25 commits behind the upstream repository.
Bo-Chun Louis Chen's avatar
3c0c30fb

This is a project implementing the blog post by Mbithe Nzomo.

Prerequisites

  • Python 2.7

  • virtualenv

  • Mysql

     $ brew update && brew install mysql
  • Flask

     $ pip install Flask

Resources:


Known Problems

  1. flask development mode WARNING

    $ flask run
     * Serving Flask app "run.py"
     * Environment: production
       WARNING: Do not use the development server in a production environment.
       Use a production WSGI server instead.
     * Debug mode: off

    Solution: Add environment variable FLASK_ENV and set it to development

    $ export FLASK_ENV=development
  2. ValueError when click on Assign in employees admin page

    file "APP_ROOT/venv/lib/python2.7/site-packages/wtforms/ext/sqlalchemy/fields.py", line 189, in get_pk_from_identity
    ValueError: too many values to unpack

    Solution(for now): Modify line 189 in fields.py from

    188 def get_pk_from_identity(obj):
    189 	cls, key = identity_key(instance=obj)
    190 	return ':'.join(text_type(x) for x in key)

    to

    188 def get_pk_from_identity(obj):
    189 	cls, key = identity_key(instance=obj)[:2]
    190 	return ':'.join(text_type(x) for x in key)
  3. When use SQLite as database

    OperationalError: (sqlite3.OperationalError) no such table

    Solution: Move sqlite database file into app directory

    $ mv app.db app/
  4. FSADeprecationWarning while accessing database using SQLAlchemy

    APP_ROOT/venv/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS
    adds significant overhead and will be disabled by default in the future.
    Set it to True or False to suppress this warning.

    Solution: Set SQLALCHEMY_TRACK_MODIFICATIONS to False/True at line 789 in flask_sqlalchemy/__init__.py

    788 track_modifications = app.config.setdefault(
    789 	'SQLALCHEMY_TRACK_MODIFICATIONS', False
    790 )