Assignment: Blogz (Create Dynamic User Pages)


Hi everyone. I’ve completed most of Blogz, but I am having trouble with the Create Dynamic User Pages sections. Some of my trouble is with the wording of the instructions, but most of it is my lack of understanding about queries and how to pass parameters properly. I appreciate any advice on how to approach this section.

Here are some of my questions and concerns about this task:

  1. In the instructions, it says that we will need to use a GET request on the /blog path with ?user=userID as the query parameter. Query parameters still seem vague to me. Is it similar to how the index handler works in the Get It Done project? I’m lost on how to create one and how to pass parameters through queries (especially when the /blog path has to handle more than one GET request; my attempts negatively affected the other GET request.

  2. When it comes the templates for the singleUser and index, would we be using dot notation that combines both tables or could dot notation be handled by the associated variables (maybe owner?) in one of the classes?

  3. I don’t understand what the instructions mean by amending the /blog route handler to render the correct template because it made it seem like the queries have to be in that handler instead of one query being in the index and the other being in the blog. I don’t even know if I’m saying this correctly.

I tried to do pseudocode for all of this, but it’s all still not making sense to me.


Queries can do lots of things, but basically, they allow you to use python code to ask about data that is in a table or database. For the dynamic user pages, we have to create a URL for the page that is based on the id of the user. That id can be found in, for example, the User table. So, it is the coder’s task to figure out what user a browser is trying to access, what that user’s id is, and then to pass that id to another function, which is the function that sets up the user’s dynamic page. We have covered passing code through arguments from one function to another. Once the user’s page retrieves the id you have sent, you can use the user’s id to reconstruct the entries created by that user, probably using jinja’s loop-based conditional functions.


Yes, it is similar to the index handler in Get It Done.

Recall back in Build-a-blog, from your main blog page that shows all blog entries, each time you clicked on a blog title, you get sent to the page showing just that blog entry. The blog titles on the main page each had url’s that was something like this: …/blog?id=some_integer

Anything following the “?” in the url is your query parameter. You can have more than one query parameter. id is the query parameter in that example and in your route handler(for /blog), you probably pulled it down using a request.args.get then queried the database asking for the row of data whose primary id is id, then rendered a template showing the title and entry on its own page.

In Blogz, functionally, it’s the same for the user pages. …/blog?user=userID now user is your query parameter. Take the same steps within your route handler. Pull down the userID then query your database for all rows containing that userID, then render your template by passing to it whatever your database query retrieves for you. The template is the same as the page that shows you all the blog posts from all users. The difference is in what the database retrieves based on what you are querying for.

The instructions about amending your /blog route handler just mean that it has to handle whatever query parameter you’re giving it. It could be just an id for a single blog entry or it could be a userID which means it wants you to get all posts from that user.

Does that help?


@Mystified13 @irwint I’m still confused about queries, but I was able to get some additional help in class on it. The parameters are really tricky. Hopefully, I’ll understand it better with more practice. Thank you both for your help!


You are welcome. I don’t know quite how to put this, but at a certain point I just kind of “got” queries. Hope it’s the same for you!