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

  • Home
  • SEARCH
  • 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 6144957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:43:32+00:00 2026-05-23T18:43:32+00:00

I have a form in my Django that looks something like this: class PersonnelForm(forms.Form):

  • 0

I have a form in my Django that looks something like this:

class PersonnelForm(forms.Form):
    """
    Form for creating a new personnel.
    """
    username = forms.RegexField(
        required=True, max_length=30, label=_("Name")
    )
    is_manager = forms.BooleanField(
        required=True, label=_("Is Manager")
    )

I use this form in two places in my site. One one of the places, I’d like to display the form and all of its fields except the is_manager field but I would like to set the default value of this field to True. In the other place, I’d like to display the form and all of its fields including the is_manager field and I would like it to have a default value of False.

How can I accomplish this? Seems to be a trivial thing but I can’t figure it out.

Thanks.

  • 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-23T18:43:32+00:00Added an answer on May 23, 2026 at 6:43 pm

    You could use the form’s __init__ method to hide (or delete) the field, i.e.

    class PersonnelForm(forms.Form):
        """
        Form for creating a new personnel.
        """
        username = forms.RegexField(
            required=True, max_length=30, label=_("Name")
        )
        is_manager = forms.BooleanField(
            required=True, label=_("Is Manager")
        )
    
        def __init__(self, *args, **kwargs):
            delete_some_field = kwargs.get('delete_some_field', False)
            if 'delete_some_field' in kwargs:
                del kwargs['delete_some_field']
            super(PersonnelForm, self).__init__(*args, **kwargs)
            if delete_some_field:
                del self.fields['is_manager']
                # or
                self.fields['is_manager'].widget = something_else
    
    #views.py
    form = PersonnelForm(...., delete_some_field=True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form in Django that looks like this: class SettingForm(forms.Form): theme
I have a form in Django that looks like this class FooForm(forms.ModelForm): foo_field =
I have a form in my forms.py that looks like this: from django import
Say I have django model that looks something like this: class Order(models.Model): number =
Weird problem in Django with forms : I have a Form.class defined like this
I have a form like: #forms.py from django import forms class MyForm(forms.Form): title =
So I have a few Django models that look like this: class City(models.Model): name
I have a django template that looks like this: <head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js type=text/javascript></script> <script
I have a factory method that generates django form classes like so: def get_indicator_form(indicator,
I have a form like so: from django import forms from django.contrib.auth.models import User

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.