上面那个例子的form声明,本来就没有user
class AccountItemForm(forms.Form):
item_type_choice = ((1, "支出"), (0, "收入"),)
datetime = forms.DateTimeField(label="帐目日期")
detail = forms.CharField(widget=forms.Textarea, label="帐目明细", max_length=65535)
money = forms.DecimalField(label="单位金额", min_value=0.01, max_digits=10, decimal_places=2)
quantity = forms.IntegerField(label="数量", min_value=1)
account_type = forms.ChoiceField(label="帐目类型", required=True, widget=forms.Select, choices=(),)
item_type = forms.ChoiceField(
label="帐目操作",
required=True,
widget=forms.RadioSelect(renderer=RadioCustomRenderer),
choices=item_type_choice,
initial='1')
def set_item_type_choices(self, request):
//blablabla