NotImplementedError: Operator 'getitem' is not supported on this expression (Flask error)

Viewed 19

I've been following this flask web app tutorial and am trying to rework things to my aim. I'm going to try my best to be as explicit as possible.

    <ul class="list-group list-group-flush" id="notes">
  {% for queen in rote.comment %}
  <li class="list-group-item">
    {{ queen }}
    <!--<button type="button" class="close" onClick="deleteNote({{ queen.id }})">
      <span aria-hidden="true">&times;</span>
    </button>-->
  </li>
  {% endfor %}
</ul>

With the above segment, I want for all logged in users to be able to access all stored notes on the database irrespective of the fact they made them or not.

    @views.route('/', methods=['GET', 'POST']) #note send
@login_required
def home():
    if request.method == 'POST':
        note = request.form.get('note')
        section = request.form.get('section')

        if len(note) < 1:
            flash('Note is too short!', category='error')
        else:
            new_note = Note(comment=note, user_id=current_user.id, section=section)
            db.session.add(new_note)
            db.session.commit()
            flash('Note added!', category='success')

    return render_template("home.html", user=current_user, **rote=Note**)

I have this code portion in my "views.py" file. My guess is that it'll store the content of the Note class in that rote variable but I'm apparently wrong because it's been giving me a NotImplementedError: Operator 'getitem' is not supported on this expression error.

0 Answers
Related