I've been struggling with this literally for hours.
I'm trying to use a ModelForm with initial values being set as those
that are already in the DB for a user. This works marvelously for
every field that I have EXCEPT for the one manytomany field I have in
my model. For that one, I can submit the form just fine, but it NEVER
prepopulates with initial data.
I'll make things more concrete. I have the following in my model
(which is made into a ModelForm):
class UserProfile(models.Model):
barmembership = models.ManyToManyField(BarMembership,
verbose_name="the bar memberships held by the user",
blank=True,
null=True)
In my view, I have some code that looks like this:
userProfile = request.user.get_profile()
bar_memberships = userProfile.barmembership.all()
profileForm = ProfileForm(
initial = {'barmembership' : [bar_memberships]})
But I just can't get it to work. Is there something I'm missing here,
or does anybody have any pointers as to what I need to do to make this
work? All my other fields populate properly in this form...but this
one is causing me major headaches.
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
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.