Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Showcase Your Projects: Recap

In this section, you:

  • Created a Django model:
Python
class Project(models.Model):
    title = models.CharField(max_length=100)
    description = models.TextField()
    technology = models.CharField(max_length=20)
    image = models.CharField(max_length=100)
  • Learned about ORMs
  • Learned about relational databases
  • Peeked into a Django migrations file
  • Peeked into a SQLite database file
  • Revisited nested folder structure
  • Added static image files to your project
  • Linked those image files correctly
  • Used the Django shell to create and edit data in your database
  • Created new URL paths
  • Queried the database from your views
  • Passed data on to your template files:
Python
return render(request, "template.html", {"projects": projects})
  • Used Django Templating Syntax for code logic and variables
  • Applied Bootstrap styling
  • Did some serious debugging

00:00 Welcome to this final video of Part 4. This was a big one. We did a lot of things in this section. We created Django models, talked about how this works, and how it relates to relational databases.

00:14 We learned about what an ORM is, an object-relational mapper, and how it maps from Python code to SQL and eventually into the database system. Then, we learned about what relational databases are, just in an overview.

00:32 We took a peek into a Django migrations file and also took a look into what is a SQLite database file that Django is working with, and how does it look inside of there?

00:44 We revisited the nested template folder structure in Django, so, what we used for templates previously, now, we also used it for static files.

00:53 We added static image files to our project, and then also, later on, linked those image files correctly with using {% load static %} and then the template tag static and the path to our static file.

01:07 We repeatedly used the Django shell to create and edit data in our database so that you know that there’s a way that you can go inside of your database and make changes by using the terminal.

01:20 We also created a couple of new URL paths and routed them correctly. We queried the database from within our views: we built a view function, did a database query, and then passed this data on to our template files.

01:38 Inside of our template files, we used the Django templating syntax, so both for code logic with these squiggly brackets and then the % sign.

01:46 We created a for loop to iterate over all our entries in the database, and then the double squiggly brackets in order to print out something, to show something in the HTML on the page.

01:59 And, we applied some more Bootstrap styling to make our app look nicer. Finally, what we also did is some serious debugging and that’s, in my opinion, the most important part of this section.

02:10 There’s always going to be something that you run into. Maybe you had a different understanding of a situation, then what turns out to be true, and that’s all fine. Like, keep a cool head, take a look at what you can find, investigate, make sure that you understand what’s going on, and then fix the problem.

02:27 That’s what debugging is all about. You don’t want to end up with a crappy situation just because you didn’t bother digging into what’s going on. Okay. Don’t be afraid to refactor and change your code to make it better and more structured and more applicable to what you’re actually trying to do. Great!

02:46 So, thanks for joining for this section. In the next one, in Part 5, we’re going to go ahead and fix the one thing that we haven’t built out yet—it’s going to be a big revisit also—and we’re going to learn about a couple of new concepts.

03:00 Our main task is going to be to make those buttons functionable so that we can access a different page that shows us a details view of the entry in our database, the specific project.

03:13 We’re also going to learn about template inheritance in this, and we’re going to keep going over the same process of developing by adding URL paths, creating our views, creating templates, making sure everything looks nice. Great! See you in Part 5.

Become a Member to join the conversation.