Conceptually, an interface element of my application can either be
click through (i.e. requires user interaction) or auto-cycle (no user
interaction).  So its boolean.  But i picked the wrong one when I
originally designed the model and now we have existing data and I
don't want to change it.

So I have a database field

class MyModel(Model):
 click_through = models.BooleanField(
                                     . . .                                 )

And a modelform:

class MyForm(ModelForm):

    class Meta:
        model = MyModel
        fields = ('name', 'click_through')

However, come interface tweaking time (now), we decided we want to
display a page with a check box "Auto Cycle?" instead of "click-
through", so I basically need to invert the actual value with respect
to this interface .

What is the easiest way to implement this?

I realize i could create a custom Field class and override to_python
to invert the value after the Form is submitted, but how about
inverting the value after i initiall load an instance of the value and
before it goes into the form, so that it displays a checked box if
click-through is False and vice-versa?  Is there an override similar
to to_python for this, or is there another way of going about it?


Thanks,

Ben

-- 
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