Giter Club home page Giter Club logo

wdc-django-basic-views's Introduction

rmotr.com

Django Basic Views

Setup Instruction

You can copy and paste each of the following directly into the terminal:

$ mkvirtualenv -p $(which python3.5) django_basic_views
$ 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_basic_views/views.py, and complete the proper URLs in django_basic_views/urls.py.

Running the development server with $ make runserver, you'll be able to test your views in the browser by pointing to http://localhost:8080/<path-for-your-view>, or if you're using Cloud9 then the URL will look like https://<project-name>-<your-c9-username>.c9users.io/<path-for-your-view> C9 should provide you a link when you run the server, just click through the warning.

1. hello_world view:

Implement a simple view under the /hello-world URL path 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 the /date URL path that returns a string with current date using the datetime library.

3. my_age view:

Implement a view under the /my-age/<year>/<month>/<day> URL path 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 the /next-birthday/<birthday> URL path 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 the /profile URL path that renders the profile.html template. You'll need to use the render() function imported from Django. Also make sure to check what variables the template is going to look for and provide render() with a context dictionary that has those variables as keys (you can choose whatever you'd like for the values).

6. authors and author views:

The goal for this task is to practice routing between two URLs. You will have:

  • /authors which renders a list of Authors (the template is provided already)
  • /author/<authors_last_name> which renders the detail view for each given author, using the AUTHORS_INFO context dictionary provided to you.

The first view just needs to render the given authors.html template.

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 check that the variables the author.html template is looking for match the keys of the context dictionary you are sending.

wdc-django-basic-views's People

Contributors

zonagilreath avatar ivanzugnoni avatar santiagobasulto avatar

Watchers

James Cloos avatar Blake avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.