Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

attributeError: can't set attribute with flask-SQLAlchemy [duplicate]

I'm using Flask-SQLAlchemy version 2.1 which installs sqlalchemy version 1.x.

My below code which first fetch an array of resultset and then loop over to modify an existing attribute used to work but now it does not.

question_topic = Question.query.join(Topic).join(User,User.id==Question.user_id).add_columns(User.email,Question.question, Question.date, Topic.topic_name, Question.id, Topic.question_id)\
        .filter(Question.id == Topic.question_id).all()



for q_t in question_topic:
    q_t.topic_name = q_t.topic_name + "some text..."

I get following error: attributeError: can't set attribute with 'topic_name'

like image 775
user1501382 Avatar asked May 30 '16 06:05

user1501382


Video Answer


1 Answers

I had the same error ("AttributeError: can't set attribute" error) on a new column. It was due to a @property that I had previously added and that had the same name than the column.

like image 103
Eino Gourdin Avatar answered Sep 28 '22 08:09

Eino Gourdin