Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Using Databases in Python Meet Peewee Modeling

I need help understanding the definition of model

model - A code object that represents a database table What does it mean "code object"? I know what an object is but everytime Kenneth used the word he was talking about the class.

1 Answer

First of all, I think you should check out the official docs from Peewee that shows how the Model corresponds to the database "things": http://docs.peewee-orm.com/en/latest/peewee/models.html

The docs should hold more authority in terms of what a Model is. There they have something like this:

[Thing | Corresponds to…] Model class | Database table Field instance | Column on a table Model instance | Row in a database table

Now, bearing in mind that an object is an instance of a class, I think we can safely assume that Kenneth probably meant that a model is a class that represents a database table.

If you talk about objects and classes a lot, you're bound to say one in place of the other. Like, I meant to say "classes and objects" just now (instead of "objects and classes" ) 🤦 - a joke btw

Thanks a lot! This really helped.