Posted on Sep 15th, 2022
๐๏ธ Todayโs topics
- React Trivia progress
- Finding & fixing bugs in React Trivia
- Deploying to Netlify
๐ฏ Project
The React Trivia application is due on Monday. It should meet at least the minimum functional requirements and is deployed to Netlify. ๐
Minimum functional requirements:
- A user can see a list of categories.
- A user can select one category.
- A user can see questions for that category, with answer options for each question.
- A user can select an answer for a question.
- A user can see if that answer is the correct answer.
- A user can go back to the category list and start over.
It would be awesome if:
- The answers are shuffled so that the correct answer is not always in the same position.
- The questions are shown one at a time instead of all at once, and the user is able to advance through the set of questions.
- A user can see how many questions they answered correctly (or some kind of score) when they have answered all the questions in a category.
๐ Read | ๐บ Watch | ๐ง Listen
๐ Resources
๐พ Code
Posted on Sep 15th, 2022
๐๏ธ Todayโs Topics
- Views and viewsets
- Nesting and customizing serializers
- Permissions
๐ฏ Project
Keep on with your API building ๐ ๐ช! What do you need to know to get it working?
By now you should have a list of endpoints that your API offers, even if they are not all complete yet. A good place to document this list of endpoints would be in your README, formatted with Markdown. This list should show the URLs along with the HTTP methods/verbs, and ideally should include an example of the JSON that has to be included in the request body (for any requests that send data in the body) and an example of the JSON response that will be returned, for each endpoint. This list will be helpful for your own testing and it can serve as necessary documentation for your API.
Here is an example of what your documentation might look like for an endpoint to create a book:
Create a new book
request
Requires authentication.
title
and author
are required fields.
POST api/books
{
"title": "The Anatomy of Melancholy",
"author": "Robert Burton",
"publication_year": 1621
}
response
201 Created
{
"pk": 6,
"title": "The Anatomy of Melancholy",
"author": "Robert Burton",
"publication_year": 1621,
"featured": false,
"reviews": []
}
By today or tomorrow, your app should respond with JSON data to GET requests for all habits(or books), for a single habit(or book), and for one habitโs (or bookโs) associated objects (daily records for habits; reviews or trackers for books). By tomorrow you should also have at least some of your POSTs working, and can begin working on UPDATE and DELETE.
๐ Make sure you test your endpoints in Insomnia to confirm that they are returning what they should, and NOT returning what they shouldnโt. Use show_urls
from django-extensions to help you check what urls you have defined.
Is your app deployed to Heroku yet? ๐ ๐
๐ Resources
Serializers
Permissions
๐พ Code
Posted on Sep 13th, 2022
๐๏ธ Todayโs Topics
- Getting data on the page with AJAX
- Troubleshooting AJAX requests
- Using multiple components and conditional rendering to create multiple views of your application
๐ฏ Project: React Trivia
This project is due next Monday.
React Trivia. Your goal today is to get a list of trivia categories showing on the page.
Remember to take it step by step! Donโt try to do too much at once.
Goals in the order you should tackle them:
- Get a list of categories from the Trivia API showing up on the page.
- Make your trivia categories selectable. When a user clicks on a category to select it, you should make a request to get at least 10 questions for that category (note: the API will let you specify how many questions you want to get back and it will let you specify the type โ you can limit to the multiple type choice to make it a little easier).
- If you can get all the questions for the selected category, the next step is to show the questions. Ideally you want to show one question at at a time with answer choices for that question.
- If this is too hard, just show the first question to start with.
- Next, show the answer choices for that question (donโt worry about the order at first; you can change that later).
- When you can show one question with its answer choices, then make it possible for the user to see the next question in the list of questions by clicking a button
- Make it possible for the user to select their answer choice. You will need to know what answer they selected, and you will need to know the correct answer. They got the answer right if the answer they selected is the same as the correct answer (so youโll need to compare those two values somehow).
- Tell the user if they got the question right.
- OR keep track of questions answered correctly and tally them at the end (something like, โYou got 6 out of 10 questions right!โ).
- Have a way for the quiz to end and optionally go back to the list of categories to start another quiz.
Donโt skip steps. They build on each other.
If you read a step and donโt know how to do it, break it down into smaller steps. You may find that you need to do this a few times to break tasks down into smaller and smaller bits. This is more than OK: itโs a smart way to work, and all developers do it.
By Thursday you should aim to have the first three goals done โ or at least, the first two and the third in progress.
๐ Resources
๐พ Code & Notes
Posted on Sep 13th, 2022
๐๏ธ Todayโs Topics
Today we dive into Django REST Framework. ๐คฟ
๐ฏ Project: Choose Your Own Adventure ๐ช ๐ซ
Choose one of the following options.
The application must be deployed to Heroku, whichever option you choose. ๐
๐ช OPTION ONE: Add an API to Habit Tracker
Add a new app to your existing Habit Tracker project and call it api
. Your app should provide CRUD endpoints that return JSON responses.
By Friday afternoon, you should be able to do almost all of the following via the API โ that is, by making requests using Insomnia.
- get a list habits
- create a new habit
- get data about a specific habit that includes its associated daily records, if any
- create a record for a specific habit for today (stretch: create a record for any date)
By Monday, you should be able to complete all necessary CRUD tasks through the API:
- list habits
- create a new habit
- update a habit
- delete a habit
- get data about a specific habit that includes its associated daily records, if any
- create a record for a habit for today (stretch: create a record for any date)
- update a record for a habit
- delete a record from a habit
Write up a list of endpoints you think you will need before you start doing this. Donโt make endpoints you donโt need.
You should develop and test your endpoints using Insomnia. (You can also use the browsable API that DRF gives you in the browser, but you should be comfortable using Insomnia.)
๐ซ OPTION TWO: Django Library API
Link to assignment invitation.
Create a new API-only application that lets users keep track of books they are reading, want to read, or have read, and take private or public notes on books. More details about project requirements are included in the assignment README.
You should not make forms or templates for this app, but you will need models, urls, views, and serializers. You should use class-based views and return JSON responses.
๐ Read | ๐บ Watch | ๐ง Listen
๐ Resources
Blog articles that go with Lacey Williams Henschelโs talk
๐พ Code & Notes