Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Help with Formset (I think it is formset I need) [RSS Feed]

#1 June 21, 2010 05:33:02

Bryan A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Help with Formset (I think it is formset I need)


Hello:

I am trying to create a form with a check box list for Tags associated
with an Appointment.

Form:
Please list tags for this Appoingmen _ Work
_ School
_ Other

I need to design this so users can add additional tags later.

Appoitnemts and Tags are M2M related:

class Appointment(models.Model):
name = models.CharField(max_length=64)

class Tag(models.Model):
name = models.CharField(max_length=64, unique=True)
appointments = models.ManyToManyField(Appointment)

My Forms Class:

class TagForm(forms.Model.Form):
tags =
forms.ModelMultipleChoiceField(queryset=Tag.objects.all(),

widget=forms.CheckboxSelectMultiple() )

class Meta:
model = Tag

In my view I have also tried:

TagFormSet = modelformset_factory(Tag, form=TagForm)
tag_form = Tag = TagFormSet(query =
Tag.object.all())

This looks right when the form is displayed, exepct the form is
duplicated once for each Tag in my Db, and clearly this is not pulling
or saving to the Db correctly.

I have looked through the Django documentation, but cannot figure out
how to implement the formset correctly (I think it is a formset I need
here).

Any help would be greatly appreciated.

Thanks.

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Help with Formset (I think it is formset I need) [RSS Feed]

Board footer

Moderator control

Enjoy the 13th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support