Saturday, June 25, 2011

how to override a ModelChoiceField in order to add FKs directly in a TextInput?

I can get text inputs rendered fine by setting the widget to a
TextInput like so:

myrelation = ModelChoiceField(MyRelatedClass.objects.none(),
widget=TextInput)

But I still get ModelChoiceField validation errors on validate:

'Select a valid choice. That choice is not one of the available
choices.'

Can I disable the ModelChocieField validation or override it? Or can
I override the ModelChoiceField entirely? I tried using

myrelation = IntegerField(widget=TextInput) but get:

Cannot assign "123": "MyClass.relation" must be a "MyRelatedClass"
instance.

Any tips would be greatly appreciated.

Tony

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate