Conventions used
There are a number of text conventions used throughout this book.
Code in text
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “This request applies the GET
request to access the api.trip.com
endpoint and addresses the hostels
resource.”
A block of code is set as follows:
class AddressViewSet(viewsets.ModelViewSet): queryset = Address.objects.all() serializer_class = AddressSerializer
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
1 from rest_framework import generics 2 from .models import Address 3 from .serializers import AddressSerializer 4 5 class AddressList(generics.ListCreateAPIView): 6 queryset = Address.objects.all() 7 serializer_class = AddressSerializer 8 9 class AddressDetail(generics. RetrieveUpdateDestroyAPIView): 10 queryset = Address.objects.all() 11 serializer_class = AddressSerializer
Any command-line input or output is written as follows:
$ curl -d '{"hostel_id":24, "start":"2024/03/01", "end":"2024/03/06"}' -H "Content-Type: application/json" -X POST http://api.trip/v1/hostels/
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “In the Name and Address fields, enter the values of your choice.”
Tips or important notes
Appear like this.