This lab will expand your blog capabilities! After this lab you will be able to comment on specific blog posts. This will demonstrate a One-to-Many relationship, where one post can have many comments.
- Create a comment database model
- Make a corresponding front end that allows users to create comments
- Show a list of all posts and their comments
- Fill in the
Comment(ndb.Model)with aStringPropertyfor a name, aTextPropertyfor the comment, and aDateTimePropertythat automatically records the date the record was created. - Add a
comment_keysvariable to thePostmodel and have it store a repeated list ofKeyPropertys - Fill in the
CommentHandlerclass so it can handle apost()request and will create a new comment and store it in the appropriate Post.
- We have retrieved the post for you by storing its key in a hidden input field in the front end form
- Open
index.htmland fill in the necessary HTML to make a form that posts to/commentand sends the commenters name and comment to the back end.
- Make the site look better with CSS and more creative HTML
- Validate comment content and commenter name
- Add an email field
- Try to flip the relationship and store the single post on each comment
- How does this change your needs on the front end?