Luís Marques
Luís Marques

Reputation: 1001

Diference between appengine_django BaseModel and db.Model

I'm using the Google App Engine helper for Django. This helper includes the following lines in its template:

from appengine_django.models import BaseModel
from google.appengine.ext import db

# Create your models here.

Should I derive my models from db.Model or from BaseModel? I've tried both and I don't see any difference. Both seem to work, even when using Django forms. Is there any reason not to delete the BaseModel import and derive all models from db.Model?

Upvotes: 1

Views: 668

Answers (2)

Djangonaut
Djangonaut

Reputation: 5821

The BaseModel also does a registration of the inherited model inside django (so f.e. you can request it by calling django.db.models.loading.get_model('app_lable.ModelName') and all other stuff related to this)

Upvotes: 1

Nick Johnson
Nick Johnson

Reputation: 101139

BaseModel is a class defined by the Django helper. It extends db.Model in order to make Django work with it better. The reason you need to import both is because the property classes are still used directly from db - but if you use db.Model instead of BaseModel, you may find some features of Django that don't work as expected.

Upvotes: 0

Related Questions