hi, I need some help here :), I have these models:
class name(models.Model): member = models.ForeignKey(member, related_name="owner") class User(models.Model): member = models.ForeignKey(member) class VirtualHost(models.Model): member = models.ForeignKey(member) ServerName = models.ForeignKey(name, unique=True, related_name='sn') ServerAlias = models.ManyToManyField(name, null=True) Given a 'User', I want to make a QuerySet in order to get all 'names' with the same member of this 'User', and are neither a ServerName nor a ServerAlias. In other words, I want a queryset that obtains the same names as this 'for' do: names = [] for i in name.objects.filter(member=user.member): if not VirtualHost.objects.filter(ServerName=i): if not VirtualHost.objects.filter(ServerAlias=i): names.append(i) I need it in a queryset version in order to use in a ModelForm like this: class VirtualHostForm(ModelForm): def __init__(self, user, *args, **kwargs): super(VirtualHostForm, self).__init__(*args, **kwargs) self.fields['ServerName'].queryset = """names""" self.fields['ServerAlias'].queryset = """names""" many thanks!! -- Marc -- 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.