I did a bit of playing around and found the same as you did.

I think the bottom line is that a boolean field of any type can only realistically hold two values. The NullBoolean must only be a workaround to support various form logic.

If you truly need a third value then an IntegerField is probably your best bet.

Mike

On 18/03/2012 8:10am, Ben Racine wrote:

yes.

On Mar 16, 2012 8:07 PM, "Mike Dewhirst" <mi...@dewhirst.com.au <mailto:mi...@dewhirst.com.au>> wrote:

    On 17/03/2012 11:02am, Ben wrote:

        I have a NullBooleanField that I would like to show up in my admin
        interface as radio buttons with unknown selected by default.

        # I have the following simplified files

        ## models.py ##
        class Value(models.Model):
            presence = models.NullBooleanField(default=False)


    Have you tried

       presence = models.NullBooleanField(default=None)


    ??



        ## admin.py ##
        PRESENCE_CHOICES = ((True, 'True'), (False, 'False'), (None,
        'None') )
        class ValueAdmin(admin.ModelAdmin):
            formfield_overrides = {
                models.NullBooleanField: {'widget':
        RadioSelect(choices=PRESENCE_CHOICES)}
            }
        admin.site.register(Value, ValueAdmin)

        This behaves very closely to what I desire, but I don't know
        what I
        could replace the False with in:
        presence = models.NullBooleanField(default=False)
        in order to make it behave as I would like.

        Thanks so much for your time,
        Ben R.


-- You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    To unsubscribe from this group, send email to
    django-users+unsubscr...@googlegroups.com
    <mailto:django-users%2bunsubscr...@googlegroups.com>.
    For more options, visit this group at
    http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to