[Flask] Issues with Flash_session - Cannot add dict item ..

Gergely Polonkai gergely at polonkai.eu
Tue Sep 24 14:11:53 EDT 2019


My first thought, without actual code to look at, is that you import
session from flask globally, but you also create a session variable
somewhere which is an instance of flask_session.Session.

Can this be your culprit? Or are you positive that the session variable you
use is the same as the one you create?

Best,
Gergely

On Tue, 24 Sep 2019, 17:15 Ben Duncan, <linux4ms at gmail.com> wrote:

> Ok, am i missing something ?
>
> View:
>
> from flask import Flask, render_template, request, redirect, url_for,
> flash, make_response, escape, g
> from flask_session import Session
> from flask_sqlalchemy import SQLAlchemy
> from flask import session
>  .....
>
> app = Flask(__name__)
> print 'APP is : ', app
> csrf = CSRFProtect(app)
>
> session = Session()
> session.init_app(app)
>
> When I try to do something like this:
>
> session['modified'] = False
>
> I get :
>
>    - e
>    "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/flask/app.py",
>    line *1935*, in dispatch_request
>
>    return self.view_functions[rule.endpoint](**req.view_args)
>
>    - File "/data/flask/applications/myproject/wtform.py", line *334*, in
>    contact
>
>    session['modified'] = False
>
>
> TypeError: 'Session' object does not support item assignment
>
> What Am I doing wrong .... ?
>
>
> *Ben Duncan*
> DBA / Chief Software Architect
> Mississippi State Supreme Court
> Electronic Filing Division
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20190924/97d0a955/attachment.html>


More information about the Flask mailing list