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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:11:02+00:00 2026-05-26T16:11:02+00:00

In my app model, I have a BooleanField : campaign = models.BooleanField(default=False, db_index=True, verbose_name=_(‘processed’),

  • 0

In my app model, I have a BooleanField:

campaign = models.BooleanField(default=False, db_index=True,
    verbose_name=_('processed'), help_text=_('Campaign or not ?'))

I use this to distinguish between two things. So, I thought of sending this value as hidden from an html form:

<input type="hidden" name="campaign" value="True or False" />

but it seems that forms send strings and I want to convert that string into a Boolean. Of course, I can re-write the model, make it a CharField with a default='True or False' value, but that does not seem very elegant.

Is there a more djangoic way to do this?

  • 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-26T16:11:03+00:00Added an answer on May 26, 2026 at 4:11 pm

    forms send strings and I want to convert that string into a boolean.

    All data in request.POST comes as strings or lists of strings. You need to convert it yourself or use django forms (preferred) which do the the work for you.

    With django forms you can replace the widget when you initiate forms.BooleanField like this:

    class MyForm(forms.ModelForm):
    
        campaign = forms.BooleanField(widget=forms.HiddenInput())
    

    More info on django forms

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

Sidebar

Related Questions

I have a four classes: class A(models.Model): field1 = models.BooleanField(default = True) class Meta:
I have a django app with models as follows: A Question model An Answer
For example I have in my app model User, that has_many models Post. And
Hello i'm working on a blog app and I have a model: class Post(models.Model):
I have: NotificationModel = App.BB.Model.extend({ defaults : { read : false }, urlRoot :
I have an already existing app with alot of database entries . class Foo(models.Model):
I am working with Google App Engine and Python. I have a model with
I have a Comment model in my app but am encountering a lot of
I have a failing model.save() in my Django app. How can I see the
In my GWT app I have the following model class: import com.google.gwt.user.client.rpc.IsSerializable; public class

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.