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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:29:35+00:00 2026-06-09T19:29:35+00:00

I have a model with DecimalField : points_player1 = models.DecimalField(max_digits=3, decimal_places=1, blank=True, null=True) When

  • 0

I have a model with DecimalField:

points_player1 = models.DecimalField(max_digits=3, decimal_places=1, blank=True, null=True)

When I displaying this field in template, it always shows values like 0.0 or 1.0 etc.
But I want to make this behavior more user-friendly:

  1. If user input, for example, is 1 it displays 1 (now its 1.0).
  2. If user input is 1.5 it should displays 1.5.
  3. By-default value is 0, not 0.0.

What is the best way to make this? Is DecimalField is right choice for my case?

  • 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-09T19:29:36+00:00Added an answer on June 9, 2026 at 7:29 pm

    You can do {{decimal_field|floatformat}} in the template, which will round off and show “.0” only when necessary.

    More reference template – floatformat

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

Sidebar

Related Questions

I have a model like this. #models.py class Payment(models.Model): unit_price = models.DecimalField(max_digits=12, decimal_places=2) discount
I have this models: class BillHeader(models.Model): billno = models.IntegerField(primary_key=True, blank=True) class BillData(models.Model): price =
I have this models: class Balanta(models.Model): data = models.DateField() class Conturi(models.Model): cont=models.PositiveIntegerField() cont_debit=models.DecimalField(default=0, max_digits=30,
I have a model: class ItemPrice(models.Model): price = models.DecimalField(max_digits=8, decimal_places=2) # ... I tried
I have a field that I usualy set as rate = models.DecimalField( max_digits=2, decimal_places=1,
I have a model which looks like this: class MyModel(models.Model) value = models.DecimalField() date
Following is the models.py: class UserProfile(models.Model): user = models.OneToOneField(User) belongs_to_user_category = models.ForeignKey(UserCustomCategory, null=True, blank=True)
I have two classes: class Order(models.Model): ... date = models.DateTimeField(blank=True, verbose_name=u'Date add',default=datetime.now) price =
I have a model: class picture(models.Model): name = models.CharField(null=False, blank=False, max_length=128) collections = models.ManyToManyField('collection',
I have a model form that contains a DecimalField() with max_digits set to 5.

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.