Thanks for your suggestion.
Products have their own part_number, but their property are very
different.
class Product_1(models.Model):
part_number = models.CharField(maxlength=20, unique=True)
property_1_1 = models....
property_1_2 = models....
property_1_3 = models....
...
class Product_2(models.Model):
part_number = models.CharField(maxlength=20, unique=True)
property_2_1 = models....
property_2_2 = models....
property_2_3 = models....
...
...
class Product_n(models.Model):
part_number = models.CharField(maxlength=20, unique=True)
property_n_1 = models....
property_n_2 = models....
property_n_3 = models....
...
Do you mean this? -->
class Product(models.Model):
part_number = models.CharField(maxlength=20, unique=True)
property_1_1 = models....
property_1_2 = models....
property_1_3 = models....
property_2_1 = models....
property_2_2 = models....
property_2_3 = models....
...
property_n_1 = models....
property_n_2 = models....
property_n_3 = models....
...
But this is a waste of the database space ( every product will store
so many empty value ) and also is not efficient to my another
application which need only query in a specific type ( for example,
Product_1 ).
So, I need different tables ( multiple models ).
Thanks very much.
On 6月30日, 下午11时17分, "Andrews Medina" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> 2007/6/30, Davide.D <[EMAIL PROTECTED]>:
>
>
>
>
>
>
>
> > Hi All,
>
> > There are n Classes in myapp/models.py
>
> > class Product_1(models.Model):
> > part_number = models.CharField(maxlength=20, unique=True)
> > ...
>
> > class Product_2(models.Model):
> > part_number = models.CharField(maxlength=20, unique=True)
> > ...
>
> > ...
>
> > class Product_n(models.Model):
> > part_number = models.CharField(maxlength=20, unique=True)
> > ...
>
> > and I want to get the Product for a specific part_number by querying
> > over all tables(Product_1, Product_2, ..., Product_n).
>
> For solution these your problem, create only a model, adding a field
> that it represents the table.
> And for unique part_number for a table ( type ) use the META option
> unique_together
> Ex:
>
> class Product(models.Model):
> part_number = models.CharField(maxlength=20)
> type = models.IntegerField()
> ...
>
> class META:
> unique_together = (("part_number", "type"),)
>
> --
> Andrews Medinahttp://pyman.blogspot.com/www.andrewsmedina.com.br- 隐藏被引用文字 -
>
> - 显示引用的文字 -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---