I got this Error when I hit the submit from

'ManagementForm data is missing or has been tampered with']


class Course(models.Model):

    course = models.CharField(max_length=30)
    course_name = models.CharField(max_length=30)

class Student(models.Model):
   
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    grade     = models.CharField(max_length=2, 
choices=YEAR_IN_SCHOOL_CHOICES

class ContestScore(models.Model):
    student =  models.ForeignKey(Student)
    course  =  models.ForeignKey(Course)
    score   =  models.FloatField()
    def  __unicode__(self):
        return u"%s - %s - %s" % (self.student, self.course, self.score)


In the view


def grading_student(request, school_id=1, student_id=1):
    student = Student.objects.get(pk=student_id)
    ContestInlineFormSet = inlineformset_factory(Student, Score,   extra =0)

    if request.method == "POST":
        formset = ContestInlineFormSet(request.POST,  instance=student)
          
            # Do something. Should generally end with a redirect. For 
example:
        return HttpResponseRedirect(reverse ('contest:gradings', 
args=(school_id),))
    else:
        formset = ContestInlineFormSet(instance=student)
    return render_to_response("grading_student_form.html",  
RequestContext(request, { "formset": formset}))



the formset = ContestInlineFormSet(instance=student) render the page good. 
But when I click submit to post data 
the formset = ContestInlineFormSet(request.POST,  instance=student) give me 
the error

ManagementForm data is missing or has been tampered with']

Please help! What I am doing wrong here? 
If the model has only one foreign key it work fine.
Thanks.





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to