Hi All,
I'm rather new to django (and python) so I tend to get lost sometimes:
I'm looking to limit the choices in a ManyToMany relationship:
class Computer(models.Model):
host = models.CharField(max_length = 20, unique = True)
def __unicode__(self):
return self.host
class Configuration(models.Model):
name = models.CharField(max_length = 20, unique = True)
hosts = models.ManyToManyField(Computer)
def __unicode__(self):
return self.name
admin.py has a "filter_horizontal = ('hosts',)" in the
ConfigurationAdmin class. So, in the admin interface, for each
Configuration I create, I can populate the "Chosen hosts" form
table from the "Available hosts" form table.
So far so good, now I would like the "Available hosts" form table
to show only hosts that's not part in *any* previous Configuration,
i.e. when I've used up all hosts, the "Available hosts" form table
should be empty. What's the best way to solve this? By using
limit_choices_to somehow I guess.
Any ideas appreciated
/Lars
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---