Grace Hopper Center

CSC 221 Weekly Assignments: Week 17

CSC 221


Overview

Happy New Year! Hope you spent the last ~20 days thinking nonstop about all of the fun things you'll build with Django =). We're excited to work together to make those dreams a reality.

PCEP study sessions will be available this Saturday, January 10 and next from 9 am to 12 noon. This will be your last opportunity to prepare for and retake the certification exams during our course. Please let us know if you plan to attend.

Thursday, January 8th

Grade Update

As promised, your git repos were evaluated in the wee hours of Thursday morning. This time email Jeff if you've got a beef with your grade. He enjoyed learning from your posts and getting a sense of where y'all are at, especially from commit comments like Madi's im very confused, Yara's Dr Chuck did not help, and Tai-Yu's finished the 3rd video, a lot was learned. I want to make sure Owen shares his Fixing the error, all I had to do was reset the database and it works now commit with Chris! We are using a flipped classroom approach with the very aim of addressing the confusion and dissonance that comes from your independent investigation outside the classroom. We want to provide you with the scaffolding you need to be successful, but that only works if you put in the work.

Certification Update

There are several of you who are hoping to complete certification exams soon - some of you need to pass the WDE certification so that you can qualify for ITP225 next semester, and others are hoping to retake the PCEP. If this is you, Make sure you're making a plan with Chris and/or Jeff!

Classwork

Today we're going to put a bow on our study of Django models. We're going to step away from our chat project and away from curses and just focus on models.

We'll start with a quick review of the one-to-many relationships that we learned from Dr. Chuck's videos.

I'll walk through the solution to last class's chat assignment. Feel free to reference my example here:

Model Design Activity

We decided to skip this activity because we ran out of time. I'm keeping it here for posterity's sake, but you are not responsible for it.

Our goal will be to write data model diagrams, turn them into python classes, and then use the DJango ORM to create and read objects.

By the end of class, each group will share the diagram that they came up with. For credit, commit the following to your repo:

  • Your ER Diagram (it can be a photo)
  • Your models in db/models.py
  • Test your models via the REPL at python3 manage.py shell and save your output to a text file

Homework

Next class we'll leave DJango models behind and move on to the next important Django module - templates. To prepare for our activities in class next week, watch and take notes on these videos.

I'll give a bit of introduction in class to help you figure out which parts to pay attention to.

From this page: Django Templates and Videos , watch these three videos:

  • Using Templates in Django (10:05)
  • Using the Django Template Language (DTL) (11:00)
  • Django Template Inheritance (6:06)

Add your notes by 11:59pm Saturday so that we can evaluate before class on Monday. As always, be prepared for a potential reading quiz.

Tuesday, January 6th

Classwork

We closed out 2025 a little bit chaotically. Today, you'll download our solution for the chat app. You'll work with your partner to make sure that you can run it, and then you'll extend it to add a new model.

Grade Update

First, take a look at your grades. Chris added two new grades: one for your notes on the SQL Murder Mystery, and one for the effort that you put into the chat project. We spent several class periods on this activity, so Chris was looking for commits to your repo that make it clear you were putting in consistent effort from the time we introduced the project on December 5th through the last day of class on December 20th. We know that not everyone got the project completely working, so this grade reflects consistent effort, not perfect code. Here is how the grade was assigned:

There are a few of you who got E's because I could not find any commits related to this project, but I know you were working in class. If that's you, check your link on this page and make sure I'm grading the correct repo. If you need to update that link or have any other questions about your grade, email Chris!

Tasks

Then, extend the chat app. The current code works great if you only ever chat with a single partner. When you start the app, it loads your whole chat history. But it doesn't know about multiple partners. If you start a chat with a new partner, it will still load your entire chat history from anyone you've ever chatted with. Follow these instructions for today's activity:

  1. Get our solution code working. You and your partner should both download the code from here and follow the instructions in the README file to get it working. Make sure that you and your partner can both run this code and can chat with each-other before continuing. Once you have it working, commit this code into your own repo.
  2. Add a new model to db/models.py called Contact which will keep track of who you're chatting with. For now, your contact only needs a name.
  3. Review Dr. Chuck's One-To-Many lesson, which will teach you how to connect your Message model with your Contact model. As always, you should be taking notes in a Markdown file that summarize the key points from this lesson and should be prepared in case we have a reading quiz next class.
  4. Modify db/models.py to add a One-To-Many relationship between the Message and Contact models.
  5. Choose how you'll test the new relationship. You can either:
    • use the Django shell as described in Dr. Chuck's video. If you do this, write a Markdown file that includes the shell commands you ran to test, and commit it to your repo.
    • If you're up for the challenge, you can modify socket_chat_curses.py to ask for your chat partner's name at the start of the chat.

Homework

Use your 90 minutes of homework time to continue today's classwork activity. Even if you don't complete it, make sure you're making commits that show your progress.

This assignment is due Wednesday at 11:59 pm so that it can be evaluated before you come to class on Thursday.