First of all you might want to reconsider not using the name "type" for one of your fields as it is a builtin in python.
I guess what you could do it limit the choices using the choices keyword in the field constructor. However, since this appears to be dynamic you would need to set it in the model's constructor, e.g. class Hardware(models.Model): ... def __init__(self, *args, **kwargs): self.fields['hardware_type'].choices = HardwareType.objects.all().values_list('pk', 'name')) I'm guessing at what the fields on HardwareType might be here. Euan On Jun 23, 2:06 am, cat in a tub <luj...@gmail.com> wrote: > Hi All, > > I want to built a django application for hardware compatibility > testing > Some hardwares are compatible with certain mother board. And > attributes of each hardware are different (I use a ugly table to store > attributes), which are compatible with Hardware types, such as MEM as > SIZE, HDD has Firmware ver... > > class HardwareType > ........... > > class Hardware > type=models.ForeighKey('HardwareType') > hardware_type=models.ForeignKey('HardwareType', > limited_choice_to{'compatible_type':self.type}) > attribute=ManyToManyField('hardwareAttribute') > > class HardwareAttribute > compatible_type=models.ForeighKey('HardwareType') > > I use limited_choice_to to limit the available options in the admin > (show compatible ones only) > But it doesn't work. The error is 'self is undefined ...' > > Any one here has any idea how to to this ? > > Thanking you in advance. > > Homer -- 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.