Hello I am making a blogging website with flask, flask-sqlalchemy, and flask-login. I am trying to figure out a way to add optional data such as a role after the account creation. This is as far as I have gotten:
@app.route('/addpinfo', methods=["POST", "GET"])
@login_required
def accountinfo():
if request.method == "POST":
username = current_user.username
job = request.form.get("role")
user_job = Loginbase(job=job)
db.session.add(user_job)
db.session.commit()
return redirect(url_for("homebase"))
else:
return render_template("accountspecs.html")
Here is what the HTML looks like:
<form method="post">
<script src="{{url_for('static', filename='js/accountspecs.js')}}"></script>
<input class="dissapointment form-box" type="text" placeholder="Write a hobby or job title"name="role"><br>
<button class="cool-sub" type="submit" name="submit">Add Role Info</button>
</form>
Does anyone know where I can go from here? I have been having trouble trying to find a way to add that element to the account the user is currently using.
Thank you for any help ahead of time.