我有表格代码,我想通过表格保存数据。自定义表格是:-
<form class="well span12 c1" name="contacts" method="POST">
<label>First Name</label>
<input type="text" placeholder="Your First Name" class="span12" required name="firstname" >
<label>Last Name</label>
<input type="text" placeholder="Your Last Name" class="span12" required name="lastname" >
<label>Email Address</label>
<input type="text" placeholder="Your email address" class="span12" required name="email" >
<label>Subject</label>
<select class="span12" name="subject" id="subject" required >
<option value="na" selected="">Choose One:</option>
<option value="service">General Customer Service</option>
<option value="suggestions">Suggestions</option>
<option value="product">Product Support</option>
</select>
<label>Message</label>
<textarea rows="8" class="input-xlarge span12" id="message" name="message" required ></textarea>
<button class="btn btn-primary pull-right" style="border-radius:0px;" type="submit">Send</button>
</form>
视图.py:-
@app.route('/contact' , methods = ['GET' , 'POST' ])
def contact():
if request.method == 'POST':
user = user_email(firstname = request.form['firstname'] ,
lastname = request.form['lastname'],
email = request.form['email'],
subject = request.form['subject'],
message = request.form['message'])
user.save()
return render_template('index.html')
else:
return render_template('contact.html')
出现 AttributeError 错误:“数据库”对象没有属性“模型”。请帮我解决这个问题。