<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-05-11 16:51 GMT+02:00 Carlos Catucci <span dir="ltr"><<a href="mailto:carlos.catucci@gmail.com" target="_blank">carlos.catucci@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class=""><div class="gmail_extra"><br><div class="gmail_quote">2015-05-11 16:46 GMT+02:00 Carlos Catucci <span dir="ltr"><<a href="mailto:carlos.catucci@gmail.com" target="_blank">carlos.catucci@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">in effetti provo e ti dico</blockquote></div><br></div></span><div class="gmail_extra">provato ma mi da sempre lo stesso errore. <br></div><div class="gmail_extra">Premetto che ho controllato e non ci sono array o valori multipli nei parametri. <br></div><div class="gmail_extra">Non riesco a capire dove possa essere il problema. Ecco il codice completo, magari auta<br><br>def add_new_router(request):<br><br>    retval = None<br><br>    if 'data' in request.POST:<br><br>        data = json.loads(request.POST.get('data', ''))<br><br>        try:<br><br>            hoster_address = HostersAddress.objects.filter(pk=data['hosters_address_id'])<br><br>            new_router, created = Routers.objects.get_or_create(<br>            {<br>                'mac_address': data['mac_address'],<br>                'uuid': data['uuid'],<br>            },<br></div></div></blockquote><div><br></div><div>acc, qui mac_address e uuid li stai passando dentro un dizionario e invece sono dei kwargs<br><a href="https://docs.djangoproject.com/en/1.8/ref/models/querysets/">https://docs.djangoproject.com/en/1.8/ref/models/querysets/</a><br><br></div><div>prova nel formato:<br>Routers.objects.get_or_create(<br></div><div>mac_address=data['mac_address'],<br></div><div>uuid=data['uuid'],<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra">            defaults={<br>                'hosters_address_id': hoster_address[0].id,<span class=""><br>                'router_pubblic_ip': data['router_pubblic_ip'],<br>                'active': data['active']<br>            })<br>            <br></span><span class="">            if created == True:<br><br>                new_router.save()<br><br></span>            retval = 'OK'<span class=""><br><br>        except Exception, ex:<br><br>            print ex<br></span>            retval = ex<br><br>    return HttpResponse(retval)            <br><br>def fill_routers(request):<br><br>    for hoster_address in HostersAddress.objects.filter(active=True,deleted=False):<br><br>        mutable = request.POST._mutable<br>        request.POST._mutable = True        <br>        request.POST['data'] = json.dumps({<br>            'mac_address': generate_mac_addr(),<br>            'uuid': generate_uuid(),<br>            'hosters_address_id': <a href="http://hoster_address.id" target="_blank">hoster_address.id</a>,<br>            'router_pubblic_ip': generate_ip(),<br>            'active': True,<br>        })<br>        request.POST._mutable = mutable        <br>        new_router = add_new_router(request)<br><br>    return HttpResponse('OK')<br></div><div class="gmail_extra"><br>La fill_routers chiama la funzione dove poi e' contenuta la get_or_create.<br></div><span class=""><div class="gmail_extra"><br clear="all"></div><div class="gmail_extra">Carlos<br></div><div class="gmail_extra">-- <br><div><div dir="ltr"><div><div dir="ltr">EZLN ... Para Todos Todo ... Nada para nosotros<br></div></div></div></div>
</div></span></div>
<br>_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@lists.python.it">Python@lists.python.it</a><br>
<a href="http://lists.python.it/mailman/listinfo/python" target="_blank">http://lists.python.it/mailman/listinfo/python</a><br>
<br></blockquote></div><br></div></div>