views:

264

answers:

2

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?

A: 

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.

Nick Johnson
But, for instance, the article http://code.google.com/appengine/articles/djangoforms.html uses Django forms with the db.Model. So it seems rather vague, "some features" might not work, and even Google articles neglect BaseModel. I'll be on the safe side and use BaseModel, but I would like to better understand which problems might arise. Is it only the model registration that "Pydev UA" refers in the other answer?
Luís Marques
Luis, if you want a more complete answer to this question, you might want to unmark this as the accepted answer. I certainly would like to know more about this subject. I completely agree with your statement "I would like to better understand which problems might arise" if one uses db.Model instead of BaseModel. I also agree with the part where you say their docs are "rather vage, 'some features' might not work".
allyourcode
+1  A: 

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)

Pydev UA