$ mkvirtualenv -p $(which python3) django_practice_1
$ pip install -r requirements.txt
You can now run the development server:
$ make runserver
The structure of the whole Django project is built for you. Your job is to implement the views that are under django_practice_1/views.py
, and complete the proper URLs in django_practice_1/urls.py
.
Running the development server with $ make runserver
, you'll be able to test your views in the browser pointing to http://localhost:8080/<some-path>
Implement a simple view under /hello-world
URL that returns a 'Hello World' string. Use the function HttpResponse()
imported from Django.
In order to check if you've successfully completed this task you can run the following command. Check code inside tests.py
if you want to see how a (simple) test is written in Django.
$ make test
Implement a view under /date
URL that returns a string with current date using the datetime library.
Implement a view under /my-age/<year>/<month>/<day>
URL that returns a string with the format: "Your age is X years old" based on given /year/month/day that come as parameters.
Implement a view under /next-birthday/<birthday>
URL where birthday
parameter is a string with the format "YYYY-MM-DD". The view should calculate the amount of days until next birthday and return a string with the format "'Days until next birthday: XYZ'"
Implement a view under /profile
URL that renders the profile.html
sending the given dictionary as context. You'll need to use the render()
function imported from Django. Also make sure to complete the template with the context data in the proper places.
The goal for this task is to practice routing between two URLs. You will have:
/authors
--> contains a list of Authors (template is provided to you)/author/<authors_last_name>
--> contains the detail for given author, using the AUTHORS_INFO provided to you.
First view just have to render the given authors.html
template sending the AUTHORS_INFO as context.
Second view has to take the authors_last_name
provided in the URL, look for for the proper author info in the dictionary, and send it as context while rendering the author.html
template. Make sure to complete the given author.html
template with the data that you send.