In a formset in Django, how do we set a default value for a field which needs a value from the http session? Since a session is required to get the value, we cannot set a default value in the model class itself. And I am not able to understand how to explicitly set the value in each form in the formset before saving in the view function.
Setting the initial attribute in the construction of the FormSet would work but for whatever reason, I get a compilation error. The code is like this:
formset = LineItemsInlineFormSet(initial=[{'updated_by':'user'}])
The compilation error is: init() got an unexpected keyword argument 'initial'
I am using Django 1.1.1
Any insight will be appreciated. Thanks in Advance.