Database Blog Posts Lab
What You Will Learn:
- Create a blog post database model
- Make a corresponding frontend that allows users to create posts
- Show a list of all posts
Why This is Important:
This lab will help you create your own Blog backend! After this lab you will be able to write simple posts and store them in between visits to your blog.
Directions
- Fill in the
Post(ndb.Model)with aStringPropertyfor a title, aTextPropertyfor the content, and aDateTimePropertythat automatically records the date the record was created. - Fill in the
get()ofMainHandlerso it queries for all the posts and sends it to the template to render- It might be good to just print the values to the console or send the raw text with
self.response.writeuntil you flesh out the frontend
- It might be good to just print the values to the console or send the raw text with
- Build up the frontend HTML so it can display all the posts.
- Add a form to the front end that posts to the
/root url with a new title and content for a post. - Fill in a
post()method inMainHandlerthat gets the data from the form, creates a newPost, and stores it in the datastore.
Stretch
- Use the Users api to replace the person posting with the signed in Users
- Make the site look better with CSS and more creative HTML
- Validate content and user name.
- Add an email field