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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:22:46+00:00 2026-06-16T04:22:46+00:00

i have a very simple IntegerField in one of my models. models.py ## Imports

  • 0

i have a very simple IntegerField in one of my models.

models.py

## Imports

from django.db import models

class UserModel(models.Model)
    name = models.CharField(max_length=50)


class NumberModel(models.Model)
    user = models.ForeignKey(UserModel)
    number = models.IntegerField(blank=True, null=True) # This is the IntegerField

in the views i am passing the number model itself:

views.py

def change_user_number(request):
    number = get_object_or_404(models.NumberModel, user=request.user)
    return render_to_response('change_number.html', {'number' : number }, context_instance=RequestContext(request))

Now when i use the value of the the above mentioned Integer Field in one of my custom forms, it shows up as follows:

Text Field with blank IntegerField's Value

In the template i have something like this:

template

<form id="" action="" method="POST">
    <p><label for="user_number"></label></p>
    <p><input type="text" name="user_number" id="user_number" value="{{ number.number }}" />
    <input type="submit" value="submit" />
</form>

I would want to show the value only if the value exists. I am quite sure that the value is saved as null in the database but why does it return "None".

I have also tried the following with no success.

<input type="text" name="user_number" id="user_number" {% if number.number == "None" %} value="" {% else %} value="{{ number.number }}" {% endif %} />
  • 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-16T04:22:48+00:00Added an answer on June 16, 2026 at 4:22 am

    Check if value exist:

    {% if number.number %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have very simple schema - two tables in one-to-many relationship: <hibernate-mapping package=my.app> <class
I have very simple window where I have 2 buttons - one for cancel,
Let's say we have very simple Java class MyClass . public class MyClass {
I am currently using Django Users model. Very simple. However, I'd like to add
I have very simple: [PrincipalPermission(SecurityAction.Demand, Role = Administrator)] public partial class _Default : System.Web.UI.Page
I have very simple web page example read from html file using python. the
I have a very simple model form, but for some reason, the code fails
I have very simple data model like this: create table Company ( id int
I have a feeling I'm missing one small thing. I have very simple page,
I have very simple form that gets values in JSON format from searchAlbum.php .

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.