Skip to content

KCJwhite/wdc-django-practice-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django practice nº 1

Setup Instruction

$ mkvirtualenv -p $(which python3) django_practice_1
$ pip install -r requirements.txt

You can now run the development server:

$ make runserver

Your Tasks

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>

1. hello_world view:

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

2. current_date view:

Implement a view under /date URL that returns a string with current date using the datetime library.

3. my_age view:

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.

4. next_birthday view:

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'"

5. profile view:

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.

6. authors and author views:

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 86.9%
  • HTML 7.0%
  • Makefile 6.1%