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 8769619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:23:06+00:00 2026-06-13T17:23:06+00:00

We use django admin as a client-facing backend, so we need to make it

  • 0

We use django admin as a client-facing backend, so we need to make it user friendly. I have a model with a bunch of DecimalFields representing nutritional data.

The fields all look like this:

g_carbs = DecimalField(max_digits=13, decimal_places = 8, null=True, blank=True)

If the field is left blank, or if a non-zero value is provided, the admin form looks and works great. For example, for a non-blank, non-zero value like 10.5, it displays something like 10.50000000, which is fine.

The problem is that for any 0 values, the form field displays 0E-8 which, although technically correct, is not going to cut it for my clients, who are definitely not scientists or engineers for the most part and are unfamiliar with E notation.

I am not using a custom form or any custom admin tricks. Its just what gets auto-rendered by django admin for that model. I’m considering submitting a ticket to django for this, but in the mean time is there something I can do with a custom form or something to remedy this problem?

  • 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-13T17:23:07+00:00Added an answer on June 13, 2026 at 5:23 pm

    Here’s what ended up working for me (so far). This both prevents E notation and removes trailing 0’s after the decimal point.

    class NonscientificDecimalField(DecimalField):
        """ Prevents values from being displayed with E notation, with trailing 0's 
            after the decimal place  truncated. (This causes precision to be lost in 
            many cases, but is more user friendly and consistent for non-scientist 
            users)
        """
        def value_from_object(self, obj):
            def remove_exponent(val):
                """Remove exponent and trailing zeros.
                   >>> remove_exponent(Decimal('5E+3'))
                   Decimal('5000')
                """
                context = decimal.Context(prec=self.max_digits)
                return val.quantize(decimal.Decimal(1), context=context) if val == val.to_integral() else val.normalize(context)
    
            val = super(NonscientificDecimalField, self).value_from_object(obj)
            if isinstance(val, decimal.Decimal):
                return remove_exponent(val)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use django admin for my users to add their Model objects, as you
My site makes use of Django's User Authentication User model and a custom UserProfile
I am currently facing a serious problem. I use the standard django admin interface
When i need to start new django i use django-admin startproject site1 and it
I try to display and add comment using Django admin, but Comment model use
I want to use the Django admin interface for a very simple web application
The Django admin site makes use of a really cool widget: How can I
I've notice django admin UI does not allow use name with characters that are
Reading about Django, I saw this: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-admin - the fancy simple to use admin
I have Django 1.4 and Python 2.6.6 When I use django-amdin.py startproject djproject follow

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.