hi folks, I am trying to create a custom form field, that is based on MultipleChoicefield. it populates itself from database and displays a nice multi-checkbox table for multiple photos selection for adding them to article... I've run into problems when trying to process 'initial' inside __init__:
class PhotoChoiceField(MultipleChoiceField): """ Photo selection field, that populates itself with photos from selected gallery on init """ widget = PhotoSelectWidget def __init__(self, photosize, required=True, widget=None, label=None, initial=None, help_text=None, *args, **kwargs): self.photosize = photosize super(PhotoChoiceField, self).__init__(choices=(), required=required, widget=widget, label=label, initial=initial, help_text=help_text, *args, **kwargs) ... self.gallery=Gallery.objects.get(pk=initial) ... Form class has 'initial' attribute set: class AttachForm(forms.Form): sel_photos = PhotoChoiceField(label = _('Select photos from the gallery'), photosize = _('admin_thumbnail') form = AttachForm(initial={sel_photos':request.GET.get('album')}) But it seems that i cannot get 'initial' set at Form level processed at Field level. It is always None. I need to pass some aadditional arguments to fields when creating form instance, can somebody give me a hint on how to do that? Fedor -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.