On Fri, May 1, 2009 at 1:58 AM, Ramashish Baranwal <
ramashish.li...@gmail.com> wrote:

>
> >
> > > I want to create several tables with same schema. This is to partition
> > > the data into different tables. Apart from having model classes with
> > > same definition, is there another way to do it?
> >
> > > Here is a trivial example that duplicates the class definition-
> >
> > > class Person(models.Model):
> > >    first = models.CharField(max_length=16)
> > >    last = models.CharField(max_length=16)
> >
> > > class Person2(models.Model):
> > >    first = models.CharField(max_length=16)
> > >    last = models.CharField(max_length=16)
> >
> > > Apart from the code duplication, the above doesn't capture the intent
> > > that the two models represent tables with same schema. I'm looking for
> > > something like-
> >
> > > class Person2(Person):
> > >    pass
> >
> > > The above however doesn't work.
> > > Any idea?
> >
> > > Thanks,
> > > Ram
> >
> > I'd do it with one class that has all the common fields that is an
> abstract
> > class(check the docs for this).  And then just 2 classes that subclass
> it.
> > This should do just what you want.
> >
> Hi Alex,
>
> Thanks for the quick reply. Abstract class fits the need perfectly.
> However, I am using Django 0.96 where abstract class functionality is
> not available. I can't upgrade  Django currently.
> Any other way?
>
> -Ram
> >
>
Unfortunately no, you probably just need to write out all the fields
manually on both models.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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