I've managed to do it my defining the superclass in another module and importing it from your 'apps/appname/models/appname.py' file. That other module can live under your models directory, just give it a different name than appname.py. I guess it works because the dynamic model "compiler" doesn't treat it like a real model which should make a table of (the attributes & methods are inherited, though).
Hope it helps, Alberto Eric Walstad wrote: > 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;