I'm currently using an environment variable to hide my API's key. My unit test that is testing the API route is now failing. However, when the key was hard-coded into the main file, the tests passed. Here is my code:
import os
import requests
key = os.environ.get('key')
def test_code(state, API_BASE_URL):
url = f'https://covid-19-testing.github.io/locations/{state.lower()}/complete.json'
res = requests.get(url)
testing_data = res.json()
latsLngs = {}
for obj in testing_data:
if obj["physical_address"]:
for o in obj["physical_address"]:
addy = o["address_1"]
city = o["city"]
phone = obj["phones"][0]["number"]
location = f'{addy} {city}'
location_coordinates = requests.get(API_BASE_URL,
params={'key': key, 'location': location}).json()
lat = location_coordinates["results"][0]["locations"][0]["latLng"]["lat"]
lng = location_coordinates["results"][0]["locations"][0]["latLng"]["lng"]
latsLngs[location] = {'lat': lat, 'lng': lng, 'place': location, 'phone': phone}
return latsLngs
Here is the unit test:
from unittest import TestCase, mock
from models import db, User
from sqlalchemy.exc import InvalidRequestError
class UserViewTestCase(TestCase):
"""Test views for users."""
def setUp(self):
"""Create test client, add sample data."""
db.drop_all()
db.create_all()
self.app = create_app('testing')
self.client = self.app.test_client()
self.testuser = User.signup('test',
'dummy',
'test123',
'dummytest#test.com',
'password',
None,
"Texas",
None,
None)
self.uid = 1111
self.testuser.id = self.uid
db.session.commit()
def test_map_locations(self):
"""Does the map show testing locations?"""
with self.client as c:
resp = c.get('/location?state=California')
html = resp.get_data(as_text=True)
self.assertEqual(resp.status_code, 200)
self.assertIn('San Francisco', html)
I also think it's important to note that the application runs fine in the browser. It's just that the unit tests are not passing anymore.
UPDATE
Here is the full traceback:
ERROR: test_map_locations (test_user_views.UserViewTestCase)
Does the map show testing locations?
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/azaria-dedmon/covid-19/tests/test_user_views.py", line 157, in test_map_locations
resp = c.get('/location?state=California')
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 1006, in get
return self.open(*args, **kw)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/testing.py", line 227, in open
follow_redirects=follow_redirects,
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 970, in open
response = self.run_wsgi_app(environ.copy(), buffered=buffered)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 861, in run_wsgi_app
rv = run_wsgi_app(self.application, environ, buffered=buffered)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 1096, in run_wsgi_app
app_rv = app(environ, start_response)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/travis/build/azaria-dedmon/covid-19/app/__init__.py", line 111, in show_state_locations
latsLngs = test_code(state, API_BASE_URL)
File "/home/travis/build/azaria-dedmon/covid-19/app/refactor.py", line 22, in test_code
params={'key': key, 'location': location}).json()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/opt/python/3.7.1/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/opt/python/3.7.1/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/python/3.7.1/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I think it's most likely that your test framework is loading just the test_code() function from your test file, and not the fact that key is set up in the main body of the code. Perhaps moving your key = os.environ.get("key") into test_code() will solve your issue.
The environment variable needs to be set in the project's repository in travis CI so that all files have access to it. Here is the documentation on how to achieve this https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings
Related
I'm trying image upload API i'm getting the following error
127.0.0.1 "POST //upload/image HTTP/1.1" 500 -
Traceback (most recent call last):
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask_restful\__init__.py", line 272, in error_router
return original_handler(e)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask_restful\__init__.py", line 272, in error_router
return original_handler(e)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask_restful\__init__.py", line 468, in wrapper
resp = resource(*args, **kwargs)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask\views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask_restful\__init__.py", line 583, in dispatch_request
resp = meth(*args, **kwargs)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\flask_jwt_extended\view_decorators.py", line 108, in wrapper
return fn(*args, **kwargs)
File "D:\c_code\projects\python_api\resources\image.py", line 24, in post
data = image_schema.load(request.files)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\marshmallow\schema.py", line 723, in load
data, many=many, unknown=unknown, postprocess=True
File "D:\c_code\projects\python_api\.venv\lib\site-packages\marshmallow\schema.py", line 861, in _do_load
unknown=unknown,
File "D:\c_code\projects\python_api\.venv\lib\site-packages\marshmallow\schema.py", line 669, in _deserialize
index=index,
File "D:\c_code\projects\python_api\.venv\lib\site-packages\marshmallow\schema.py", line 493, in _call_and_store
value = getter_func(data)
File "D:\c_code\projects\python_api\.venv\lib\site-packages\marshmallow\schema.py", line 662, in <lambda>
val, field_name, data, **d_kwargs
File "D:\c_code\projects\python_api\.venv\lib\site-packages\marshmallow\fields.py", line 342, in deserialize
output = self._deserialize(value, attr, data, **kwargs)
TypeError: _deserialize() got an unexpected keyword argument 'partial'
The code of File "D:\c_code\projects\python_api\resources\image.py", line 24, in post is the following
from marshmallow import Schema, fields
from werkzeug.datastructures import FileStorage
from marshmallow import Schema, fields
from werkzeug.datastructures import FileStorage
class FileStorageField(fields.Field):
default_error_messages = {
"invalid": "Not a valid image."
}
def _deserialize(self, value, attr, data) -> FileStorage:
if value is None:
return None
if not isinstance(value, FileStorage):
self.fail("invalid")
return value
class ImageSchema(Schema):
image = FileStorageField(required=True)
The code is working fine when call the API image upload it is raising error.
I'm using flask marshmallow, Flask uploads, packages.
Since marshmallow 3, _deserialize may receive partial kwarg.
Every custom field should copy Field._deserialize signature and accept unknown kwargs.
def _deserialize(
self,
value: typing.Any,
attr: typing.Optional[str],
data: typing.Optional[typing.Mapping[str, typing.Any]],
**kwargs
):
Change your code like this to accept kwargs silently:
def _deserialize(self, value, attr, data, **kwargs) -> FileStorage:
if value is None:
return None
Here I am trying to fetch data from cassandra with filter() where I need to fetch students with more than or equal to 65 marks but I am getting this error can't understand why am I getting this error. I am referring this link. I have also referred similar questions on this but didn't get any solution.
Here is my python code:
from flask import *
from flask_cqlalchemy import CQLAlchemy
app = Flask(__name__)
app.config['CASSANDRA_HOSTS'] = ['127.0.0.1']
app.config['CASSANDRA_KEYSPACE'] = "emp"
db = CQLAlchemy(app)
class Student(db.Model):
uid = db.columns.Integer(primary_key=True)
marks = db.columns.Integer(primary_key=True)
username = db.columns.Text(required=True)
password = db.columns.Text()
#app.route('/merit')
def show_merit_list():
ob = Student.objects.filter(marks >= 65)
return render_template('merit.html', ml = ob)
And this is the error log I am getting:
Traceback (most recent call last)
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 2463, in
__call__
return self.wsgi_app(environ, start_response)
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 2449, in
wsgi_app
response = self.handle_exception(e)
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 1866, in
handle_exception
reraise(exc_type, exc_value, tb)
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/_compat.py", line 39, in
reraise
raise value
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 2446, in
wsgi_app
response = self.full_dispatch_request()
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 1951, in
full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 1820, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/_compat.py", line 39, in
reraise
raise value
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 1949, in
full_dispatch_request
rv = self.dispatch_request()
File "/home/sudarshan/.local/lib/python3.6/site-packages/flask/app.py", line 1935, in
dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/sudarshan/Downloads/PycharmProjects/try/try1.py", line 67, in show_merit_list
ob = Student.objects.filter(marks >= 65)
NameError: name 'marks' is not defined
Pass self object to your method, hence allowing it to access marks data member.
Change marks to self.marks.
#app.route('/merit')
def show_merit_list(self):
ob = Student.objects.filter(self.marks >= 65)
return render_template('merit.html', ml = ob)
Well finally I found the answer I was forgetting to use allow_filtering(). The code will look like following:
#app.route('/merit')
def show_merit_list():
ob = Student.objects().filter() #all()
ob = ob.filter(Student.marks >= 65).allow_filtering()
return render_template('merit.html', ml = ob)
You need to use Filtering Operators, try:
ob = Student.objects.filter(marks__gte=65)
I'm working with League of Legends API, and I'm trying to get Ranked Datas from JSON file. But, if the player is not Level 30, he doesn't have his file.
So here
def getRankedData(region, ID, APIkey):
URL = "https://" + region + ".api.pvp.net/api/lol/" + region + "/v2.5/league/by-summoner/" + ID + "/entry?api_key=" + APIkey
response = requests.get(URL)
return response.json()
It won't get JSON file, because it doesn't exist. How do i can do, that if the URL doesn't exist and doesn't have the JSON file, it returns the string.
Here, I'm returning the datas to HTML page. But this isn't work too.
region = request.form['region']
summonerName = request.form['summonerName']
APIkey = "45afde27-b628-473f-9a94-feec8eb86094"
types = request.form['types']
responseJSON = getData(region, summonerName, APIkey)
ID = responseJSON[summonerName]['id']
ID = str(ID)
responseJSON2 = getRankedData(region, ID, APIkey)
if not responseJSON2:
divisionName = "Unranked"
else:
divisionName = responseJSON2[ID][0]['name']
responseJSON3 = getChallengerPlayers(region, str(types), APIkey)
challengerPlayers = responseJSON3['entries'][0]['wins']
#print challengerPlayers
return render_template('form_action.html', ID = ID, divisionName = divisionName, challengerPlayers = challengerPlayers)
I'm getting this error:
Traceback (most recent call last)
File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\Hanisek\Documents\Visual Studio 2015\Projects\FlaskWebProject2\FlaskWebProject2\FlaskWebProject2\views.py", line 53, in hello
responseJSON2 = getRankedData(region, ID, APIkey)
File "C:\Users\Hanisek\Documents\Visual Studio 2015\Projects\FlaskWebProject2\FlaskWebProject2\FlaskWebProject2\views.py", line 21, in getRankedData
Open an interactive python shell in this framereturn response.json()
File "C:\Python27\lib\requests\models.py", line 805, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Python27\lib\json\__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
dont know a ton about LOL but is there a reason that you cant have your program use and if/then statement to check the level of the player and then only check for the json file if the player is a high enough level to have one?
You can try checking if the URL exists, JSON is proper format or if the page throws 40X status codes
try:
r = requests.get("URL")
assert r.status_code < 400
return r.json()
except (ValueError, ConnectionError, AssertionError):
return ''
It's always a good idea to check what the api url is returning by running it in your browser. I'm guessing that it's returning a 404 error because the information doesn't exist.
In that case, I recommend checking to see if there is a 404 error before proceeding with the JSON parsing.
Request has a function called status_code that will return the 404 error if there is one.
Example code:
r = request.get("API STRING")
if r.status_code != 404:
r.json()
I have database on Mysql and in project I use pony orm in Flask. I need to get row from database with index 1.
Here I have routes for routing in app
routes.py
from app import app
from pony.orm import *
from app.models import Area
#app.route("/")
#app.route("/user/")
#db_session
def user():
c = Area[1]
return c
Here I have models for my database
models.py
from pony.orm import *
import config
db = Database()
class Country(db.Entity):
id = PrimaryKey(int,auto=True)
name = Required(str,100)
area = Set("Area")
class Area(db.Entity):
id = PrimaryKey(int, auto=True)
name = Required(str, 100)
country = Required(Country)
When I open in browser address localhost:8888/ I get next error
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python34\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Python34\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python34\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Python34\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python34\lib\site-packages\flask\app.py", line 1478, in full_dispatch_request
response = self.make_response(rv)
File "C:\Python34\lib\site-packages\flask\app.py", line 1577, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "C:\Python34\lib\site-packages\werkzeug\wrappers.py", line 841, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "C:\Python34\lib\site-packages\werkzeug\wrappers.py", line 57, in _run_wsgi_app
return _run_wsgi_app(*args)
File "C:\Python34\lib\site-packages\werkzeug\test.py", line 867, in run_wsgi_app
app_iter = app(environ, start_response)
TypeError: 'Area' object is not callable
When I made error?
I'm stupid! Here solution:
def user():
c = Area[1]
name = c.name
return name
I have a form, and on submit I keep getting the error below. I can't work out what the problem is, but I think it has something to do with the selectfield as this is the first time I am using it and I haven't had problems before.
Here is my form:
class CampaignForm(Form):
name = StringField('Campaign Name', validators=[DataRequired])
start = DateField('Start', validators=[DataRequired], format='%d-%m-%Y')
end = DateField('End', validators=[DataRequired], format='%d-%m-%Y')
budget = IntegerField('Budget', validators=[DataRequired])
customer_id = SelectField(
'Customer', validators=[DataRequired], coerce=int)
Here is my view, GET works, but I keep getting an error on POST:
#app.route('/campaign/add', methods=['GET', 'POST'])
#login_required
def campaign_add():
form = CampaignForm()
form.customer_id.choices = [
(customer.id, customer.name)
for customer in current_user.account.customers]
if form.validate_on_submit():
campaign = Campaign(name=form.name.data,
start=form.start.data,
end=form.end.data,
budget=form.budget.data,
account_id=current_user.account_id,
customer_id=form.customer_id.data,
created_at=datetime.now(),
created_by=current_user.id,
updated_at=datetime.now(),
updated_by=current_user.id)
db.session.add(campaign)
db.session.commit()
return redirect(url_for('campaigns'))
return render_template('campaigns/add.html', form=form)
Here is the error that I am getting, and I can't work out what is wrong.
Traceback (most recent call last):
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/tornado/web.py", line 1309, in _execute
result = self.prepare()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/tornado/web.py", line 2498, in prepare
self.fallback(self.request)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/livereload/server.py", line 89, in __call__
WSGIContainer.environ(request), start_response)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask_debugtoolbar/__init__.py", line 124, in dispatch_request
return view_func(**req.view_args)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask_login.py", line 758, in decorated_view
return func(*args, **kwargs)
File "/home/lee/Code/fastplan/src/fastplan/views.py", line 249, in campaign_add
if form.validate_on_submit():
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask_wtf/form.py", line 166, in validate_on_submit
return self.is_submitted() and self.validate()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/form.py", line 310, in validate
return super(Form, self).validate(extra)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/form.py", line 152, in validate
if not field.validate(self, extra):
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/fields/core.py", line 200, in validate
stop_validation = self._run_validation_chain(form, chain)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/fields/core.py", line 220, in _run_validation_chain
validator(form, self)
TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given
The issue is that lines like this:
validators=[DataRequired]
should be like this
validators=[DataRequired()]