python - How to call a form.py in another application -
i have model named namemodel in app named customer. wanna reuse model's 1 of choices in app's model or forms.py. how can that. following code of form in customer app. genderchoices = ( ( "", ("---")), (6, ("male")), (7, ("female")), (8, ("notknown")), )
please help.
remember genderchoices either class member of namemodel or tuple defined @ customer app models.py
just import , use would, in models.py file:
from customer.models import namemodel examplemodel(models.model): type = models.charfield(max_length=1,choices=namemodel.genderchoices)
or ...
from customer.models import genderchoices examplemodel(models.model): type = models.charfield(max_length=1,choices=genderchoices)
if tuple not defined inside namemodel class.
cheers.
edit
to edit tuple have convert list append , convert tuple:
l = list(genderchoices) l.append(((9,("something else"))) genderchoices_extra = tuple(l)
hope helps
Comments
Post a Comment