The following code works fine:
class MyForm(forms.Form):
foo = forms.CharField()
form = MyForm(initial=request.GET) # can be accessed as http://host/view/?foo=default_value
The following code does not fetch the values from request.GET:
class Foo:
foo = models.CharField(max_length=255)
class MyForm(forms.ModelForm):
class Meta:
model = Foo
form = MyForm(Foo(), initial=request.GET) # does nothing
However, the following hack can be used to fetch the values from request.GET:
class Foo:
foo = models.CharField(max_length=255)
class MyForm(forms.ModelForm):
class Meta:
model = Foo
form = MyForm(Foo(), initial=dict(request.GET.items())) # works as expected
Suggested behaviour: initial argument to ModelForm? should accept MultiValueDict?'s, as the base Form implementation does.