I'm sure there is a simple solution here, but I've been searching the
forum archive and elsewhere but so far haven't found an answer.

I have a form that uses some dynamic ModelChoiceField fields,
filtering the model for the logged-in user.

The form in app's forms.py, slightly abridged, is like this:

class SystemAlertForm(forms.ModelForm):
    usermessaging = forms.ModelChoiceField(label='Messaging address',
queryset=UserMessaging.objects.filter(isactive=True))
    def __init__( self, user, *args, **kwargs ):
        super( SystemAlertForm, self ).__init__( *args, **kwargs )
        self.fields['usermessaging'].queryset =
UserMessaging.objects.filter(isactive=True,user=user)

Then in the view, after a POST, I have a line of code like this:

form = SystemAlertForm(request.POST, user=request.user,
instance=alert)

But there is an error: __init__() got multiple values for keyword
argument 'user'

When displaying a bound form for a user, the form is fine: it displays
this usermessaging ModelChoiceField correctly filtered -- and I call
it the same way but without the request.POST:
form = SystemAlertForm(user=request.user, instance=alert)

But, after a POST, it displays the error above.

Thanks in advance for any guidance.

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to