I'm trying to set up a many to many relationship, but when I save the model
I get "TypeError:     'layer_set' is an invalid keyword argument for this
function".

In class Experiment(Job) I declare the model with:

   layer_set = models.ManyToManyField(LayerSet, blank=True, default =
"default layer")

In class ExperimentForm(forms.Form) I assign input with:

   layer_set =
forms.ModelMultipleChoiceField(queryset=LayerSet.objects.all(),
widget=forms.CheckboxSelectMultiple, required = False)

In my views.py:

   if request.method == "POST":
       form = ExperimentForm(request.POST, request.FILES)

       if form.is_valid():
           experiment = Experiment(**form.cleaned_data)
           experiment.owner = request.user
           experiment.save()

The problem is occurring in experiment = Experiment(**form.cleaned_data).
The constructor for this is:

   def __init__(self, *args, **kwargs):
       kwargs = _append_type(kwargs)
       super(Experiment, self).__init__(*args, **kwargs)

I believe the problem lies in super() trying to find a layer_set in
Experiment, which doesn't exist since layer_set needs to be a 2nd table that
points to Experiment and LayerSet. So far my best guess is that in views.py
I need to add something like:

       if form.is_valid():
           temp_layer_set = form.cleaned_data['layer_set']            <-----
           del form.cleaned_data['layer_set']
    <-----
           experiment = Experiment(**form.cleaned_data)
           experiment.owner = request.user
           experiment.save()
           (something to save temp_layer_set to its own table)       <-----

But at this point I have no idea how to actually save the temp_layer_set. It
doesn't have its own class or anything so I can't call
experiment_layer_set.save().

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to