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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:56:11+00:00 2026-06-11T05:56:11+00:00

I have a BooleanField in a standard Django Form defined as: my_boolean_field = BooleanField(initial=True)

  • 0

I have a BooleanField in a standard Django Form defined as:

my_boolean_field = BooleanField(initial=True)

when I render my form with initial data, and my_boolean_field is set to an initial value of False, when the form renders it is still checked despite the fact that the value is false as the html shows:

<p><label for="id_2">my_boolean_field</label>: 
    <input checked="checked" 
           type="checkbox" 
           name="2" 
           value="False" 
           id="id_2" /> 
</p>

Has anyone else experienced this, or knows how to fix it so that when the initial data/input value is false then the checkbox is not checked?

UPDATE: Even if I remove the initial=True argument from the BooleanField the same thing happens.

  • 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-11T05:56:12+00:00Added an answer on June 11, 2026 at 5:56 am

    Firstly, you can’t have required=False on a BooleanField, use NullBooleanField instead:

    • https://docs.djangoproject.com/en/dev/ref/models/fields/#booleanfield
    • https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.NullBooleanField

    let me know what the HTML output of the new widget is once you’ve done this?

    EDIT

    I assumed that this is a ModelForm. Is this a regular django.forms.Form?

    EDIT 2

    My test form:

    from django import forms
    
    class MyForm(forms.Form) :
        """The test form"""
        my_boolean_field = forms.BooleanField(initial=True)
    

    My template:

    <div>
    {{ form.my_boolean_field.label_tag }}
    {{ form.my_boolean_field }}
    {{ form.my_boolean_field.errors }}
    </div>
    

    This is what I get for output when I view page source. EDITED

    <div>
    <label for="id_my_boolean_field">My boolean field</label>
    <input type="checkbox" name="my_boolean_field" id="id_my_boolean_field" />
    </div>
    

    My View NEW

    form = MyForm(initial={'my_boolean_field':False})
    

    What you are showing and what I’m seeing aren’t matching up. paste your full form, view and template please?

    EDIT 3

    I only see output like this:

    <div>
    <label for="id_my_boolean_field">My boolean field</label>
    <input checked="checked" type="checkbox" name="my_boolean_field" value="False" id="id_my_boolean_field" />
    </div>
    

    when I put False in quotes:

    form = FormLogin(initial={'my_boolean_field':"False"})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app model, I have a BooleanField : campaign = models.BooleanField(default=False, db_index=True, verbose_name=_('processed'),
I have built a django form, simple extract as follows: attachuploadediso = forms.BooleanField(label='Attach uploaded
I have the following models: class Profile(models.Model): verified = models.BooleanField(default=False) primary_phone = models.OneToOneField('Phone', related_name='is_primary',
So I have some Django 1.3 models like this: class Type(models.Model): is_bulk = models.BooleanField()
I have a four classes: class A(models.Model): field1 = models.BooleanField(default = True) class Meta:
I have the following models: class Product(models.Model): active = models.BooleanField(default=True) name = models.CharField(max_length=40, unique=True)
I have a Django model and from. class Settings(models.Model): field_1 = models.BooleanField() field_2 =
I have the following model.py : class FinancialProduct(models.Model): active = models.BooleanField(default=True) name = models.CharField(max_length=20)
I have the following two models class ModelOne(models.Model): mod_desc = models.CharField(max_length=25) is_active = models.BooleanField(default=True)
I have form: class ItemForm(forms.ModelForm): id = forms.ModelChoiceField(queryset=Item.objects.all(), widget=forms.HiddenInput()) temp = forms.BooleanField(widget=forms.HiddenInput(), required=False) date

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.