python - How to match this in an if statement -
i working django formwizard. in part want utilize if statement:
def get_form_initial(self, step): if step =='2': x = self.get_cleaned_data_for_step('0') or {} if x['color'] == 'red': no matter seek never x['color'] matching 'red'
i checked , x gets value:
{'color': <products: red>} i tried x['color']['products'] == 'red' (and lot of other options) resulted in error message.
this easy, cannot figure out......
since didn't specify model , forms using getting here, expect has this:
def get_form_initial(self, step): if step =='2': x = self.get_cleaned_data_for_step('0') or {} if x['color'].color == 'red': the x['color'] returns products object can gather , cannot see here properties has. debug seek printing x['color'].__dict__
python django
No comments:
Post a Comment