def create(): journal_entry = request.form.to_dict(flat=True) journal_entry_copy = copy.deepcopy(journal_entry) for key, val in journal_entry_copy.items(): if not bool(val): journal_entry.pop(key, None) entry_id, is_error = Journal.create_record(journal_entry) if is_error: flash('Error occured while Creating entry', 'error') return redirect(url_for('index')) return redirect(url_for('details', journal_id=str(entry_id)))