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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:00:21+00:00 2026-05-14T03:00:21+00:00

Is there a way to force django to display nothing instead of None for

  • 0

Is there a way to force django to display nothing instead of “None” for a Decimal Field that’s been left blank?

In my template, I show a list of all the values for a particular field. Each value is hyperlinked to a page that displays the results of a query filtered on that value. But because there are some entries with null value, my list includes actual DecimalField entries and “None” for all those that are empty. When a user clicks on None, django throws a validation error because you cannot query a DecimalField using a string.

I could write if statements checking all instances of decimal fields for Nones and skipping them, but that is far from an elegant solution. Any advice?

This is one part of the code, though there are other templates that derive the None value in slightly different manners:

{% for item in choices %}
    <a href={% url app_views.field_choice item %}>{{ item }}</a><br>
{% endfor %}
  • 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-05-14T03:00:21+00:00Added an answer on May 14, 2026 at 3:00 am

    If you don’t want to filter the list of values, you could use the built-in default or default_if_none template filters to control what’s displayed, but with the example given above, you’d end up with empty links.

    {{ item|default_if_none:"" }}
    

    Given your need to hyperlink and query on each value and a view which is going to show an error if not given a number, I’d filter the list when you’re passing it to the template context:

    {"choices": [choice in choices where choice is not None]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to force Django models to pass a field to a
Is there a way to force VS to use Unicode always, instead of weird
Is there a way to force DetailView/ListView to generate an XML file instead of
Is there any way to force tornado skip variables in part of template? I
In Django is there a way to force admin users to choose to fill
Is there a way to force the image to anchor to the left or
Is there any way to force Outlook to display HTML in the desktop alert
Is there any way to force Text-Mate to use a two-space tab instead of
Is there a way to force C# compiler, visual studio 2010, to call a
is there some way to force the gridview's pager to show up, even when

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.