Python Forum
filtering by category flask+mongodb
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
filtering by category flask+mongodb
#1
Hi coders! I'm dividing every page by filtering by the correct category in my recipe blog, but I don't know why I cannot manage. For example, I have vegetarian.html, It works when I simply don't look for a specific category in MongoDB, but when I do I get an error, I write here the code:

This is main.py

@app.route('/vegetarian')
def vegetarian():
    query={{"category_name": "Vegetarian"}}
    return render_template("vegetarian.html", recipes=mongo.db.recipes.find(query))
The error is this:

File "/Users/RBianco/Desktop/Course restart/cookbook-milestone/main.py", line 35, in vegetarian
query={{"category_name": "Vegetarian"}}
TypeError: unhashable type: 'dict'


For sure I wrote it wrong.

Any help please?

Thank you guys!!!
Reply


Messages In This Thread
filtering by category flask+mongodb - by Leon79 - Jul-18-2020, 05:09 PM
RE: filtering by category flask+mongodb - by Leon79 - Jul-18-2020, 05:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  category and subcategory into django project dhirendra007 0 2,004 Dec-26-2020, 10:33 AM
Last Post: dhirendra007
  Retrieve images base64 encoded MongoDB and Flask Nuwan16 2 3,315 Oct-13-2020, 06:25 PM
Last Post: Nuwan16
  Store Screenshot Selenium + MongoDB Nuwan16 9 3,649 Aug-18-2020, 03:57 AM
Last Post: ndc85430
  error when trying to update mongodb damian0612 6 3,457 Jul-04-2020, 07:25 PM
Last Post: damian0612
  Extract json-ld schema markup data and store in MongoDB Nuwan16 0 2,469 Apr-05-2020, 04:06 PM
Last Post: Nuwan16
  Flask-Sqlalchemy count products in specific category imawesome 2 29,998 Mar-12-2020, 08:14 PM
Last Post: imawesome
  storing images in mongodb using python richa828 2 9,390 Jun-06-2018, 08:08 AM
Last Post: richa828
  Begginer - How to choose a server to run my Python script with MongoDB? Mapl 1 3,758 Oct-24-2017, 01:02 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020