I have a similar issue, with a bunch of very similar apps that I need
in separate tables that all have the same base structure.  I keep the
common models in a file called models_base.py and then use execfile in
the models.py file for each app.  It's basically like a php or c
include in that in 'inserts' in the local.  You can also make changes/
add fields to a model after it's defined by placing the assignments
after the execfile.

execfile('somefilenameandpath.py',locals(),globals())

Having said that, I don't think it is generally a good idea to do
this.  It seems much better now to use subclassing with tables
specified, or some other approach.  In my case, the project was built
well before model subclassing was implemented.  Otherwise we woud have
used that.  It does work though if you have to do it that way.


On Jul 20, 7:56 pm, Andy <selforgani...@gmail.com> wrote:
> I have N models that are identical except the model names (i.e. they
> all have the same attributes, methods):
>
> MyModel0, MyModel1, MyModel2, ...
>
> Normally I'd need to type out the model definitions for those N models
> by hand inside models.py.
>
> Is there a way to generate the N model definitions programatically
> instead of manually?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to