Python (Django) Classroom Series – 02/Sept/2021

HTTP Response Codes

  • The various response or status code are grouped by the type of success of failure they indicate
    • 100-199: The server sends codes in this range to indicated protocol changes or more data is required. You don’t have to worry about these
    • 200-299: A status code in this range indicates the successful handling of response
    • 300-399: A status code in this range means page you are requesting has moved to other address (Redirection)
    • 400-499: A status code in this range means that the request could not be handled as there was a problem with the client
    • 500 – 599: Status codes in this range indicate that error is on servers side
  • For more info Refer Here

Exercise:

  1. Create a new django project bookreview in a virtual environment
  2. Add an app called as review app
  3. open this project in pycharm

Processing a Request

  • This is a basic time line of the request and response flows, so that you can get an idea of what code you will be writing does at each stage.
  • In terms of writing the code, you will first write your view. The view you created will perform actions such as querying the database. This view will pass the data to another function to render a template and finally responds with HTTPResponse
  • Django, needs to know how to map a specific URL to your view, so that it can load the correct view for the recieved URL.
  • When Django receives a request, it parses the URL config file and then finds a corresponding view

Preview

  • When we would like send the data along with the request one of the easier way of doing it is query string Refer Here

Exercise

  • Write a view in the project which takes principal, rate of interest and time and you view should return simple and compund intrest.
  • Use query string to send the p,t,r

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin