CS412
Spring 2025

Assignment 3: Getting Started with Django

due by 9:00 p.m. EDT on Friday, February 7, 2025

Preliminaries

In your work on this assignment, make sure to abide by the collaboration policies of the course.

If you have questions while working on this assignment, please post them on Piazza! This is the best way to get a quick response from your classmates and the course staff.

Learning Objectives

After completing this assignment, students will be able to:


Pre-requisites: Django Installation, Git, Heroku Client

Before you can build your first Django application, you will need to follow the instructions on Blackboard about installing Django and the requisite tools:

You will need to create a Django Project (or use the one you used with examples), and make sure that the installation worked correctly by viewing the default Django web app in your browser.

In addition, you must install the git software for source code version control and deployment.


Sample Implementation

In this assignment, you will create a “Quote of the Day” application, which will display a randomly-selected quotation by some person you deem to be famous.

Here is a sample solution: Quote of the Day Application.

You should not try to replicate this exact web application; rather this is just some guidance about what to expect.


Task 1: Your First Django Application

Create a new Django app called quotes within your cs412 Django project. Be sure to add this new app within the settings.py list of installed applications.

You will need to create an app-specific urls.py file inside the quotes directory (it is not created automatically when you create the app). Modify your main project urls.py to include the quotes/urls.py file.

Note

  • The requirements are presented here as 3 parts (URLs, views, templates).

  • You are strongly encouraged to work on one URL/ view/template at a time, and test as you go.

  • Notice the naming convention: use the same name for the URL, the view, and the template.

  1. The structure of this web application will involve the following URL patterns:

    • / : the main page, which will display a picture of a famous or notable person of your choosing and a quote that this person said or wrote. The quote and image will be selected at random from a list of images/quote.

    • /quote : the same as /, to generate one quote and one image at random.

    • /show_all : an ancillary page which will show all quotes and images.

    • /about : an about page with short biographical information about the person whose quotes you are displaying, as well as a note about the creator of this web application (you).

  2. Create the required views to support this application:

    The application will contain two Python lists in the global scope of the views.py file: a list of quotes (string), and a list of images (image URLs, as strings). Create both of these lists first, with 3 items in each list. You will add more later.

    Note: we are not using Django models in this application; we will come back to models at a later time.

    Note: the quotes and images should all be from the same one person.

    • quote : the view for the main page.

      This view directs the application to display one quote and one image.

      The view will need to select one of each of these at random, and set them as context variables for use in the HTML template.

      Finally, it will delegate work to the quote.html template for display.

    • show_all : the view to show all quotes.

      This view will add the entire list of quotes and images to the context data for the view. Finally, delegate presentation to the show_all.html HTML template for display.

    • about: the view to display information about the famous person whose quotes are shown in this application.

      Delegate presentation to the about.html HTML template for display.

  3. Create the appropriate Django HTML Templates for this project:

    • base.html: a base page that will provide a header and navigation for the page, as well as including any necessary style information.

    • quote.html : the main web page, that will show a single quote along with an image, each selected at random from a hard-coded list written in your Python code.

    • show_all.html : show all of the quotes and images, in a neatly formatted page.

      Note: this HTML template will need to use a loop to process the list of quotes, and another loop to process the list of images.

    • about.html: the about page

  4. Create/use a CSS file to style your web pages.

    You may re-use the CSS file from your previous assignments as a starting point. You may link to a CSS file on your cs-people.bu.edu site, or else create a Django static directory and put your static (e.g., .css) there. See in-class examples.

Test your application on your local development server, and resolve all syntax and logical issues. You will know when it works correctly.


Task 2: Deployment to cs-webapps

  1. Deploy your web application to the cs-webapps.bu.edu.

Follow the deployment instructions here.

  1. Test your web application on cs-webapps.bu.edu to ensure that everything works correctly.

  2. Resolve any deployment issues.


Submitting Your Work

10 points; will be assigned by the autograder, verifying that you have submitted the correct files/URL, and testing that you website exists at the specified URL. 90 points; will be testing your application and code review

Log in to GradeScope to submit your work.

Be sure to name your files correctly!

  1. Create a text file within your main django directory called a3_url.txt, containing the URL to your web page, and nothing else.

    For example: https://cs-webapps.bu.edu/azs/cs412/quotes/.

    This file will be used by the autograder to locate your web page, so you must get the URL exactly correct, and you must not include any other text or code in the file.

  2. Add teaching staff as collaborators to your GitHub repository (wderocco8, Aanuszkiewicz, and azs-bu). Read-only access is fine.

    Create a text file called github_url.txt in the root of your project (e.g., django directory). Paste your GitHub URL in the file.

    Add these files to your git repository using

    `git add -A`.
    

    Commit this to your git repository, using

    `git commit -m "Added a3_url.txt"`
    

    Push it to GitHub, using

    `git push origin main`
    
  3. Log in to GradeScope to submit your work.

    In the Gradescope upload page, upload these two files:

    • a3_url.txt

    • github_url.txt

Notes: