Let's make some ice cream!
- Fork and clone this repository.
- Install the
requirements
usingpip install -r requirements.txt
. - Run the
migrations
, create asuperuser
, and create some ice cream using the admin site.
- Go to
shops/views.py
and add aget_ice_cream
view function that takes in arequest
andice_cream_id
, andrenders
a template namedice_cream_detail.html
(you might find this link useful).- Fetch the
ice cream
object based on theid
received in the parameter. - Add the following context to be injected into your template:
name
: the ice cream's name as a string.shop
: the ice cream's shop name as a string.stock
: the ice cream's current stock as an integer.
- Fetch the
- Add your
get_ice_cream
view tobareed/url.py
.- Name it
ice-cream-detail
, and make sure to addice_cream_id
to the path.
- Name it
- Create a
templates
folder inside ofshops
and add anice_cream_detail.html
file.- The template should render the entire context passed to it.
- Run the server and check out your beautiful ice creams.
- Run the tests using
pytest -m detail
and pass all tests. - Commit your code and push.
- In the detail view, wrap your fetch in a
try-except
block and raise anHttp404
if the ice cream id does not exist. - Run the tests using
pytest -m detail_bonus
and pass all tests. - Commit your code and push.
- Go to
shops/views.py
and add aget_ice_creams
view function that takes in arequest
andrenders
a template namedice_cream_list.html
.- Your context should include the
name
s,flavors
(as a list of strings), andshop
names of all ice creams.
- Your context should include the
- Add your
get_ice_creams
view tobareed/url.py
and name itice-cream-list
. - Create a
templates
folder inside ofshops
and add anice_cream_list.html
file.- The template should render the entire context passed to it.
- Use this link to see how to loop over objects in
DTL
.
- Run the server and check out your beautiful ice creams.
- Run the tests using
pytest -m list
and pass all tests. - Commit your code and push.
Add a button that links each ice cream in the list view that redirects the user to the detail page.