1

So I have this code:

class JSONResponseJSONDumps(HttpResponse):
    """JSON response class."""
    def __init__(self, obj='', json_opts={}, mimetype="application/json", *args, **kwargs):
         content = json.dumps(obj, cls=DjangoJSONEncoder)
         super(JSONResponseJSONDumps,self).__init__(content, mimetype, *args, **kwargs)


class Equipment(models.Model):
    serial = models.CharField(max_length=64, blank=False)
    volts = models.IntegerField(blank=True, null=True)
    hertz = models.IntegerField(blank=True, null=True)
    amps = models.IntegerField(blank=True, null=True)

//views.py

      data = {
             "serial": equipment.serial,
             "hertz": equipment.hertz,
             "volts": equipment.volts,
             "amps" : equipment.amps,
             }                                
      response = JSONResponseJSONDumps(data, {}, 'application/json')

I send this back to iOS. Now, I have this weird problem where amps is being sent as a integer, and iOS sees that, and in the case of Volts and Amps, it is being sent as String?!

This has happened to me in other models as well. Any ideas?!

Thanks!

4

0 に答える 0