I'm in the process of creating an application for a personal project I'm working on that involves Python 3, peewee, and (for the moment) Sqlite3. In main, I'm importing a 2 model classes (student and course) which are subclasses of a basemodel class I create.
The import statements located in main.py:
from models.course import Course
from models.student import Student
The models/BaseModel.py
from peewee import *
db = SqliteDatabase('database/attendance.db')
class BaseModel:
class Meta:
database = db
The models/course.py
from peewee import *
from models.basemodel import BaseModel
class Course(BaseModel):
cid = PrimaryKeyField()
title = TextField()
active = BooleanField()
class Meta:
table_name = 'courses'
When I try to do a simply query to retrieve courses, I receive an error message.
Example query:
active_courses = Course.select().where(Course.active == True)
The error message I receive is:
AttributeError: type object 'Course' has no attribute 'select'
Your BaseModel class needs to extend peewee.Model:
class BaseModel(peewee.Model):
...