def create_journal(): form = JournalForm() form['csrf_token'].data = request.cookies['csrf_token'] if form.validate_on_submit(): new_journal = Journal(name=form.data['name'], color=form.data['color'], user=current_user) db.session.add(new_journal) db.session.commit() return new_journal.to_dict() return {'errors': validation_errors_to_error_messages(form.errors)}
def create_journal(): form = JournalForm() form['csrf_token'].data = request.cookies['csrf_token'] print('----------') if form.validate_on_submit(): data = Journal() print(data, '----------') form.populate_obj(data) data.userId = current_user.id db.session.add(data) db.session.commit() return data.to_dict() return 'invalid info'