Hi all,
I'd like to make a base class for my model classes that defines some
fields but doesn't result in a table in the database. If my base class
is derived from meta.Model, then django makes a table for it in the
database.
Is it possible to do what I want, move common fields to a super class,
without generating a table for that super class?
Thanks,
Eric.
contrived example follows (I don't want the 'experiment_mybaseclasss'
table created):
experiment/models/experiment.py:
from django.core import meta
class myBaseClass(meta.Model):
created_on = meta.DateTimeField(auto_now_add=True)
modified_on = meta.DateTimeField(auto_now=True)
class myDerivedClass(myBaseClass):
name = meta.CharField(maxlength=25)
class META:
module_name = 'my_derived_class'
$ django-admin.py sql experiment
BEGIN;
CREATE TABLE experiment_mybaseclasss (
id serial NOT NULL PRIMARY KEY,
created_on timestamp with time zone NOT NULL,
modified_on timestamp with time zone NOT NULL
);
CREATE TABLE experiment_my_derived_class (
id serial NOT NULL PRIMARY KEY,
modified_on timestamp with time zone NOT NULL,
created_on timestamp with time zone NOT NULL,
name varchar(25) NOT NULL
);
COMMIT;