Hello again. I know I'm posting in here all the time.

I am trying to get specific querysets in my forms based on the id in the 
kwargs but it says there is a keyerror with 'id'. It's the same 
kwargs.get('id') I reference whenever I do other stuff. Not sure why it 
doesn't like it this time. Any suggestions?

class LocGroupForm(forms.ModelForm):
class Meta:
model = LocationsGroup
fields = ('group_name', 'slug', 'customer', 'location', 'user_id',)

def __init__(self, *args, **kwargs):
qs = kwargs.pop('id')
super(LocGroupForm, self).__init__(*args, **kwargs)
self.fields['customer'].queryset = Customers.objects.get(pk=qs)
self.fields['location'].queryset = 
CustomerLocations.objects.filter(customer_id=qs)
self.fields['user_id'].queryset = 
CustomerUsers.objects.filter(customer_id=qs)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c7584d64-d6b5-46e2-ba59-7cb23b1e17bbn%40googlegroups.com.

Reply via email to