python - Django form fields dynamic subclassing -
i'm trying develop mechanism dynamically create set of django form fields.
while experimenting, encounter strange behavior, , i'd know, if worth worry about.
here code:
in [139]: django import forms in [140]: myfielddynamic = type('myfielddynamic', (forms.charfield,), {}) in [141]: 1 class myfield(forms.charfield): 2 pass in [142]: myfielddynamic.mro() out[142]: [django.utils.deprecation.myfielddynamic, django.forms.fields.charfield, django.forms.fields.field, object] in [143]: myfield.mro() out[143]: [__main__.myfield, django.forms.fields.charfield, django.forms.fields.field, object]
as see if class created using type
, first superclass django.utils.deprecation.myfielddynamic
. what's wrong thing?
and bit more broader question - possible @ all, i'm trying - create form fields @ runtime? maybe there resources, skipped?
edit:
python:
2.7.6 (default, mar 22 2014, 22:59:56) \n[gcc 4.8.2]
django:
(1, 8, 3, 'final', 0)
Comments
Post a Comment