Thanks Thomas.
Just trying to apply the DropDownMultiple Widget that you have
suggested. I have followed the instruction:
|class MyForm(forms.ModelForm):
categories = forms.Field(widget=DropDownMultiple)
def __init__(self, *args, **kwargs):
self.base_fields['categories'].widget.choices =
Category.objects.values_list('id', 'name')
super(MyForm, self).__init__(*args, **kwargs)|
And I get an exception at python level. This code seems to have been
written in 2008. I wonder if its still working with the latest python
and django. :(
As soon as I add the line
|categories = forms.Field(widget=DropDownMultiple)|
to my form i get this exception:
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in
get_response
111. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py"
in _wrapped_view
20. return view_func(request, *args, **kwargs)
File "/home/houman/projects/my/my_app/views.py" in deal_template_view
303. form = DealTypeForm(instance=deal)
File "/home/houman/projects/my/my_app/forms.py" in __init__
252. super(DealTypeForm, self).__init__(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in __init__
247. error_class, label_suffix,
empty_permitted)
File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in __init__
95. self.fields = copy.deepcopy(self.base_fields)
File "/usr/lib/python2.7/copy.py" in deepcopy
174. y = copier(memo)
File "/usr/local/lib/python2.7/dist-packages/django/utils/datastructures.py" in
__deepcopy__
129. for key, value in self.iteritems()])
File "/usr/lib/python2.7/copy.py" in deepcopy
174. y = copier(memo)
File "/usr/local/lib/python2.7/dist-packages/django/forms/fields.py" in
__deepcopy__
180. result.widget = copy.deepcopy(self.widget, memo)
File "/usr/lib/python2.7/copy.py" in deepcopy
190. y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.7/copy.py" in _reconstruct
334. state = deepcopy(state, memo)
File "/usr/lib/python2.7/copy.py" in deepcopy
163. y = copier(x, memo)
File "/usr/lib/python2.7/copy.py" in _deepcopy_dict
257. y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.7/copy.py" in deepcopy
163. y = copier(x, memo)
File "/usr/lib/python2.7/copy.py" in _deepcopy_dict
257. y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.7/copy.py" in deepcopy
190. y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.7/copy.py" in _reconstruct
329. y = callable(*args)
File "/usr/lib/python2.7/copy_reg.py" in __newobj__
93. return cls.__new__(cls, *args)
Exception Type: TypeError at /deal/add/
Exception Value: object.__new__(NotImplementedType) is not safe, use
NotImplementedType.__new__()
On 17/08/12 02:22, Tomas Neme wrote:
DropDownMultiple widget
http://djangosnippets.org/snippets/747/
--
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.