Hi All,
I am using Django 1.1, say I have a model like:
class MyModel(Model):
    someField = CharField(max_length=32)

if I have another class that receives an instance of the model, can I
read the max_length there?

class Hypothetical_form (forms.Form):
    def __init__(self, model_instance):
        self.someField = forms.CharField(label = u'Some Label', widget
= forms.TextInput(attrs={'size':
this.magicalGetSize(model_instance,'someField')}))

    def magicalGetSize(instance, fieldname):
         return some_how_find_the_max_length(instance, fieldname)

this will give me the ability to keep my db and forms sync.
Thank you for any help
Rex
disclaimer: I know about ModelForm and all that, but I want to see if
there is a way to inspect a Model's meta data and field options. I
found functions like get_field_by_name() but they are not in the
django documentation.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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