Sunday, March 1, 2015

Chapter 6 - Models and Databases

Ooh, models. Unfortunately we're not talking about extremely attractive people. According to the official Django tutorial, A model is the single, definitive source of information about your data. It contains the essential fields and behaviors of the data you’re storing. Generally, each model maps to a single database table.

Well, ok, then.

The coolest thing about this chapter is creating your superuser. Woohoo! Kind of makes you feel like you're on your way to becoming a superhero.

Note to self, this seemed important for future use:

Thought I'd put it here because it seems like something I will forget later.

Another thing about this chapter to note: 
If it bothers you (like it bothered me) that the admin interface slaps an S on Category to make it Categorys instead of Categories, the tutorial helpfully points out that you can add a nested Meta class within your Category class in models.py, to alert the admin to a special plural spelling. 

It's simply a matter of inserting this right under the __unicode__ function in your Category class:

class Meta:
    verbose_name_plural = "Categories"

...and voila. Your admin is now grammatically correct. Yay!

No comments:

Post a Comment