Monday, August 2, 2010

Error while saving custom form field

I have a custom model field defined which works pretty fine when i use
the python shell. It stores and retrieves the objects from the
database as it should. I have been trying to use this model field in
the admin form as a form field. in one of my models, this field is
supposed to be the auto generated primary key. I am able to create new
records in the database for this model/form. In my other models, I use
field as a foreign key. On the admin page for these models I get the
list of available choices I have for this field when trying add a new
record. The problem arises when I try to save/create this record. The
admin page gives a validation error stating to select a valid choice
from for this field, even though it exists.

In my new field model class i do have a method which links this model
field class to the form field class, although the form field class
doesnt have any methods. i subclassed it from TextField and hope to
use all of its methods.

Should I override the save method of the ModelForm for my admin form ?

--
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.

No comments:

Post a Comment