Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7969993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:19:36+00:00 2026-06-04T07:19:36+00:00

All the docs I’ve seen imply that you might be able to do that,

  • 0

All the docs I’ve seen imply that you might be able to do that, but there isn’t anything official w/r/t ulong64/uint64 fields. There are a few off-the-shelf options that look quite promising in this arena:

  • BigIntegerField … almost, but signed;
  • PositiveIntegerField … suspiciously 32-bit-looking; and
  • DecimalField … a fixed-pointer represented with a python decimal type, according to the docs — which presumably turns into an analogously pedantic and slow database field when socked away, á la the DECIMAL or NUMERIC PostgreSQL types.

… all of which look like they might store a number like that. Except NONE OF THEM WILL COMMIT, much like every single rom-com character portrayed by Hugh Grant.

My primary criterion is that it works with Django’s supported backends, without any if postgresql (...) elif mysql (...) type of special-case nonsense. After that, there is the need for speed — this is for a model field in an visual-database application that will index image-derived data (e.g. perceptual hashes and extracted keypoint features), allowing ordering and grouping by the content of those images.

So: is there a good Django extension or app that furnishes some kind of PositiveBigIntegerField that will suit my purposes?

And, barring that: If there is a simple and reliable way to use Django’s stock ORM to store unsigned 64-bit ints, I’d like to know it. Look, I’m no binary whiz; I have to do two’s complement on paper — so if this method of yours involves some bit-shifting trickery, don’t hesitate to explain what it is, even if it strikes you as obvious. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:19:37+00:00Added an answer on June 4, 2026 at 7:19 am

    Although I did not test it, but you may wish to just subclass BigIntegerField. The original BigIntegerField looks like that (source here):

    class BigIntegerField(IntegerField):
        empty_strings_allowed = False
        description = _("Big (8 byte) integer")
        MAX_BIGINT = 9223372036854775807
    
        def get_internal_type(self):
            return "BigIntegerField"
    
        def formfield(self, **kwargs):
            defaults = {'min_value': -BigIntegerField.MAX_BIGINT - 1,
                        'max_value': BigIntegerField.MAX_BIGINT}
            defaults.update(kwargs)
            return super(BigIntegerField, self).formfield(**defaults)
    

    Derived PositiveBigIntegerField may looks like this:

    class PositiveBigIntegerField(BigIntegerField):
        empty_strings_allowed = False
        description = _("Big (8 byte) positive integer")
    
        def db_type(self, connection):
            """
            Returns MySQL-specific column data type. Make additional checks
            to support other backends.
            """
            return 'bigint UNSIGNED'
    
        def formfield(self, **kwargs):
            defaults = {'min_value': 0,
                        'max_value': BigIntegerField.MAX_BIGINT * 2 - 1}
            defaults.update(kwargs)
            return super(PositiveBigIntegerField, self).formfield(**defaults)
    

    Although you should test it thoroughly, before using it. If you do, please share the results 🙂

    EDIT:

    I missed one thing – internal database representation. This is based on value returned by get_internal_type() and the definition of the column type is stored eg. here in case of MySQL backend and determined here. It looks like overwriting db_type() will give you control over how the field is represented in the database. However, you will need to find a way to return DBMS-specific value in db_type() by checking connection argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All the Python docs I've read appear to indicate that, side-effects aside, that if
I've been searching all over SO and reading through google docs but I can't
I've added references to all the required docs api dll's, but I still get
I have read all of the docs and there doesnt seem to be too
I've been digging through all docs I can find, but I cannot seem to
I have read all the docs I can get my hands on and google'd
All links in produced documentation are like: docs/classes/db_Foo/Bar.html . The actual filenames do not
The docs say: If not all the certificates needed to verify the leaf certificate
Hey all I just finished: http://www.mongodb.org/display/DOCS/Rails+3+-+Getting+Started#Rails3-GettingStarted-InstalltheRails3 But its not quite suited for ubuntu 10.04...
As we all know ( http://developers.facebook.com/docs/share/ ) Facebook has deprecated the share function. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.