I have a choices field called status in my model form which can be set
to a number of values, however the options available will be based on
its current state something like this, so it needs to refer to itself:

class ContractForm(ModelForm):

def getStatusChoices()
   if status == 'r':
            return (('C', 'Confirmed'), ('N', 'Cancelled))
  elif status == 'C':
            return (('M', 'Completed'), ('P', 'Paid'))
  ....

 status = fields.ChoiceField(choices=getStatusChoices())

I read in another thread that you can do this by accessing and setting
the self.fields['status'] which contains the status state  of the
current object and is created by the meta form class.  How do I access
self in the model function.  If i pass it in as a parameter to the
method as shown below what should the function call look like in the
status field, i.e. how do I refer to the current object to be passed.

        def getStatusChoices(self):
                if not self.key:
                        self.fields['STATUS'] = (('R', 'Requested'),
('C', 'Confirmed'))
                elif self.fields['STATUS'] == 'R':
                        self.fields['STATUS'] = (('N', 'Cancelled'),
('C', 'Confirmed'))
                return self

Thanks

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