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 Medina
http://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 django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to