Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14011

I'm working on Twitter Clone project and I'm trying to keep Thumbs up like icon visible I got it to toggle on and off properly

$
0
0

I'm able to toggle on and off Thumbs up icon to like and unlike messages but thumbs up icon won't stay visible.

@app.route('/messages/<int:message_id>/like', methods=['POST'])def add_like(message_id):"""Toggle a liked message for the currently-logged-in user."""    if not g.user:        flash("Access unauthorized.", "danger")        return redirect("/")    liked_message = Message.query.get_or_404(message_id)    if liked_message.user_id == g.user.id:        # Retrieve liked messages IDs from the session or initialize if not present        liked_messages_ids = session.get('liked_messages_ids', [])        if message_id in liked_messages_ids:            liked_messages_ids.remove(message_id)        else:            liked_messages_ids.append(message_id)        # Store liked messages IDs back into the session        session['liked_messages_ids'] = liked_messages_ids        db.session.commit()    return redirect("/")

I've tried adding EventListener to likes.html file but still doing the samething. I was hoping this would allow Thumbs Up icon to remain visible.


Viewing all articles
Browse latest Browse all 14011

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>