<div dir="ltr"><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><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> defaults={<br> 'hosters_address_id': hoster_address[0].id,<br> 'router_pubblic_ip': data['router_pubblic_ip'],<br> 'active': data['active']<br> })<br> <br> if created == True:<br><br> new_router.save()<br><br> retval = 'OK'<br><br> except Exception, ex:<br><br> print ex<br> 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">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><div class="gmail_extra"><br clear="all"></div><div class="gmail_extra">Carlos<br></div><div class="gmail_extra">-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">EZLN ... Para Todos Todo ... Nada para nosotros<br></div></div></div></div>
</div></div>