Re: ModelMultipleChoiceField doesn't do initial selection

2007-08-02 Thread Kai Kuehne

Forgot something:
I could print the form manually and not use form.as_table(). So I
can left out the fields I don't want. I think this is ok in this case.

Thanks!
Kai

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelMultipleChoiceField doesn't do initial selection

2007-08-02 Thread Kai Kuehne

Hi Lucky,

On 8/2/07, Lucky B <[EMAIL PROTECTED]> wrote:
>
> I think you should be using form_for_instance on the dvd instance
> instead of the generic form contructor.
> http://www.djangoproject.com/documentation/newforms/#form-for-instance

This works, and this is the way I had it first. But I don't
want to display all fields of the model. That's why I created a form
containing just a few fields of the model.

Unfortunately I cannot delete fields out of a form created with
form_for_instance:
: 'DVDInstanceForm' object does not
support item deletion

Thanks,
Kai

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelMultipleChoiceField doesn't do initial selection

2007-08-02 Thread Lucky B

I think you should be using form_for_instance on the dvd instance
instead of the generic form contructor.
http://www.djangoproject.com/documentation/newforms/#form-for-instance

On Aug 2, 11:14 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote:
> No ideas anyone? :-/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelMultipleChoiceField doesn't do initial selection

2007-08-02 Thread Kai Kuehne

No ideas anyone? :-/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ModelMultipleChoiceField doesn't do initial selection

2007-07-31 Thread Kai Kuehne

Hi list,
sorry for bugging you again but I cannot solve this problem.
In my applications I have a model DVD and a model Genre
related via a ManyToMany field. The problem is that the
edit form doesn't show the selected genres already assigned
to a DVD instance.

The form looks like:
class DVDForm(forms.Form):
...
genres = 
forms.ModelMultipleChoiceField(queryset=Genre.objects.order_by('name'))

And the view function like this:
def dvd_edit(request, slug):
dvd = get_object_or_404(DVD, slug=slug)
if request.method == 'POST':
form = forms.DVDForm(request.POST)
if form.is_valid():
for field in ['title', 'release_year', 'case_type']:
setattr(dvd, field, form.cleaned_data[field])
dvd.save()
return HttpResponseRedirect('/')
else:
form = forms.DVDForm(dvd.__dict__)

# False
print form.is_valid()
return render_to_response('dvd_edit.html', \
{'form': form, 'original': dvd},
context_instance=RequestContext(request))

Help is greatly appreciated.
Thanks for your time,
Kai

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---