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
-~----------~----~----~----~------~----~------~--~---

Reply via email to