mardi 5 mai 2015

TypeError : int() argument must be a string or a number, not 'list'

I am getting the error when i try to run this code.but it works fine on debug.

unions_choice_list = []
msss_choice_list = []
if request.method == 'POST':
    form = AnnouncementForm(request.POST, request.FILES,)
    type = request.POST.get("type")
    if type == 'individual':
        series = request.POST.get("series")
        print 'in individual'
        if series == 'union':
            print 'in series'
            unions_choice_list = request.POST.getlist('union')
            print unions_choice_list
            if form.is_valid():
                print 'in is_valid'
                for item in unions_choice_list:
                    print 'in for loop'
                    form.instance.pk = None
                    announcement = form.save(commit=False)
                    obj = Union.objects.get(pk=item)
                    announcement.union = obj
                    announcement.tittle = request.POST.get('tittle')
                    announcement.show_to = 'union'
                    announcement.save()
            else:
                messages.error(request, "Correct the displayed errors")

when i tried to print datas in console,I got the following result.

in individual
in series
[u'1', u'3']

I tried to read the matching results in this site.but those does not solve my problem.Can someone help? and can someone tall me why this runs fine on debug??

Aucun commentaire:

Enregistrer un commentaire