Ok, I’m still due to write a proper full review of Udacity’s Intro to Object-Oriented Programming course at some point (hopefully soon), but for now, I wanted to take a moment to say: I’m so glad I made myself go through all the videos there, because a lot of the confusing things from before, from when I was trying to familiarize myself with Django for the first time, aren’t so confusing anymore.

For example, here in the Django docs about models:

from django.db import models

class Person(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)

Looking at this piece of code for the first time, I HAD NO IDEA THAT models.Model referred to the models module, whose documentation can be found at https://docs.djangoproject.com/en/dev/topics/db/models/!

models.Model simply calls the Model class from he module models. It’s a standard base class that helps us create representations of data in Django. In the example above, too, class Person inherits properties from class Models.model.

Also, a key line from the docs:
“Generally, each model maps to a single database table.”

Makes a lot of sense now. We now have a database table named Person, with two columns for storing 30-character data: one to populate first_name, and another to populate last_name.

By the way, for the record, I’m still finding Mike Hibbert’s Python/Django tutorial on YouTube really helpful. I’d written previously about his videos in the context of setting up a virtualenv with Django.

If all goes well, perhaps I’ll stick with it and see how it goes. More soon.

blog comments powered by Disqus
  • Hi, I'm Linda! I enjoy going to tech meetups, learning web development, and blogging about the learning path. Follow me @LPnotes

Subscribe to The Coding Diaries