python - iterate over model field names django -


i looking create 2 models one-to-one-field, first nothing more t/f, second corresponds fields of first. if first class has true, second class takes field, such if class 1.text == true next class have class2.text set "hi, field text" whereas if class1.text false, class2.text empty string.

i implement form save second class depending on fields first has set true, iterate on field names, in if class 1 is:

class data(models.model):     fields= onetoonefield(data2)     text = booleanfield     email = booleanfield 

and class 2 is:

class data2(models.model):     text = booleanfield     email = booleanfield 

i want set field names class1 variables, , relate them that. in template:

{% field in data %}    {% if data.field == true %}       {{ data2.field }}    {% endif %} {% endfor %} 

if makes sense. how accomplish this, or there easier way relate identically named fields 2 models?


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -