Hi,
I can't see why in my application i am getting this error. As all primary keys are text fields are integers. Here is my code:
forms.py
class EventAttendForm(forms.Form):
talk = forms.ModelChoiceField(queryset=Talk.objects.all())
membersAttended = forms.ModelMultipleChoiceField(queryset=Member.objects.all())
models.py
class Talk(models.Model):
title = models.CharField(max_length=200, primary_key=True)
class Member(models.Model):
name = models.CharField(max_length=200)
membership_number = models.CharField(max_length=200, primary_key=True)
talks = models.ManyToManyField(Talk, through='Event_Attendance')
class Event_Attendance(models.Model):
talk = models.ForeignKey('Talk')
membersAttended = models.ForeignKey('Member')
views.py
def addAttendance(request):
#eventAttendanceForm
if request.method == 'POST':
eventAttendForm = EventAttendForm(request.POST)
for member in request.POST['membersAttended']:
ea = Event_Attendance(request.POST['talk'], member)
ea.save()
return HttpResponseRedirect('../../../talks/')
else:
eventAttendForm = EventAttendForm()
return render_to_response('attendance/addAttendance.html',{'eventAttendForm': eventAttendForm})
I cannot see why I am getting this error. The exact error is:
Exception Type: ValueError
Exception Value: invalid literal for int() with base 10: 'redirectTest'
RedirectTest is a Talk that I created with my form for the add talk to check that redirection was working correctly. The line of code that it is saying is causing the problem is ea.save()
Thanks in Advance,
Dean