๐๏ธ Todayโs Topics
Today we dive into Django REST Framework. ๐โโ๏ธ
๐ฏ Project: Choose Your Own Adventure
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 the following via the API โ that is, by making requests using Insomnia.
- list habits
- create a new habit
- view a habit
- update a habit
- delete a habit
By Monday, you should be able to complete all CRUD tasks through the API:
- list habits
- create a new habit
- view a habit
- update a habit
- delete a habit
- list records for a habit (this should be on the habit detail API endpoint)
- create a record for a habit
- 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!
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. Note, this is an empty repo, so you wonโt have to delete a README to start.
Create a new API-only application that lets users keep track of their books, including important information like title, author, publication date, a field that marks it as โfeaturedโ, and maybe other fields like โgenreโ if you want. Books should be unique by title and author (that is, you canโt have two books with the same title and author; two books with the same title is fine as long as the authors are different).
Anyone can add a new book as long as the same book is not already in the library. Only admin users can update book details and delete books.
Youโll also need a book tracking model so that users can mark a book as โwant to readโ, โreadingโ, or โread/doneโ. Users can also write reviews on books, which should be viewable to all users. Optionally users can take private notes on books.
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.
Your app should allow users to:
- list all books
- list all featured books
- create a book
- retrieve details about a book
- mark a book as want to read, reading, or read
- retrieve all reviews for a book
- post a review for a book
- edit their own review (not delete it)
Admin users can:
- update a book
- mark a book as featured
- delete a book
- delete reviews
๐ Read | ๐บ Watch | ๐ง Listen
๐ Resources
Blog articles that go with Lacey Williams Henschelโs talk
๐ฆ Code