question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BigIntegerField should convert to Float?

See original GitHub issue

I’m not sure what the best solution to this would be, but converting models.BigIntegerField() to graphene.Int() will often give me the error.

{
  "errors": [
    {
      "message": "Int cannot represent non 32-bit signed integer value: 2554208328"
    }
  ],
  "data": {
    "match": null
  }
}

Maybe we would be better off converting it to a graphene.Float()?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
svengtcommented, Jun 8, 2021

Thanks @brianjp93, this is still an issue in 2021 😅

You can register the custom field so it uses it automatically for every models.BigIntegerField. Run the following in an app -> ready method for example.

from django.apps import AppConfig
from django.db import models
from graphene import Field
from graphene_django.converter import convert_django_field

from .types import BigInt


class MainConfig(AppConfig):
    ...

    def ready(self):
        super().ready()

        @convert_django_field.register(models.BigIntegerField)
        def convert_field_to_big_int_field(field, registry=None):
            return Field(BigInt, description=field.help_text, required=not field.null)
1reaction
japrogramercommented, Aug 11, 2017

you might want to create your own scalar for big integers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Big integer field in django models - Stack Overflow
How to truncate a floating point number to an arbitrary decimal place? Why does the FRE() function in CBM BASIC v2 return negative...
Read more >
Model field reference - Django documentation
If the verbose name isn't given, Django will automatically create it using the field's attribute name, converting underscores to spaces. See Verbose field...
Read more >
FloatField - Django Models - GeeksforGeeks
FloatField is a floating-point number represented in Python by a float instance. ... If this isn't given, Django will use the field's name....
Read more >
How To Convert Data Types in Python 3 - DigitalOcean
This Python 3 tutorial will guide you through converting data types including ... Python's method float() will convert integers to floats.
Read more >
How to convert price datatype field to float - ServiceNow
Hi, I need to write a Client Script that get the value from a form field that has a Price datatype and convert...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found