2011-10-19 20 views
0

私はいくつかのForeignKey関係を持つモデルをいくつか持っています。 forms.pyを通じてレンダリング中のエラー: 'long'オブジェクトは反復不可能です

私はModelMultipleChoiceFieldウィジェット

class VariableFieldForm(ModelForm): 
    custom_field = forms.ModelMultipleChoiceField(queryset=VariableField.objects.all(), widget=FilteredSelectMultiple("Custom Fields", is_stacked=False)) 

    class Meta: 
     model = VariableField 

と私は、次のトレースバック

File "/opt/python2.6/lib/python2.6/site-packages/django/utils/encoding.py" in force_unicode 
    71. s = unicode(s) 
File "/opt/python2.6/lib/python2.6/site-packages/django/forms/forms.py" in __unicode__ 
    408. return self.as_widget() 
File "/opt/python2.6/lib/python2.6/site-packages/django/forms/forms.py" in as_widget 
    439. return widget.render(name, self.value(), attrs=attrs) 
File "/opt/python2.6/lib/python2.6/site-packages/django/contrib/admin/widgets.py" in render 
    39. output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)] 
File "/opt/python2.6/lib/python2.6/site-packages/django/forms/widgets.py" in render 
    581. options = self.render_options(choices, value) 
File "/opt/python2.6/lib/python2.6/site-packages/django/forms/widgets.py" in render_options 
    531. selected_choices = set([force_unicode(v) for v in selected_choices]) 

Exception Type: TemplateSyntaxError at /admin/product/subcategory/3/ 
Exception Value: Caught TypeError while rendering: 'long' object is not iterable 

を取得し保存した記録localhost:8000/admin/product/subcategory/3/にアクセスしようとしたり、新しいレコードを保存するとき、私はジャンゴを使用していますを追加しました1.3とMySQL

それを解決する方法のアイデアは?

答えて

0

私は、ManyToManyFieldリレーションの代わりにForeignKeyを使用していました。

今後の質問にお役立てください。

関連する問題