R – Admin Form Integration for Custom Model Fields in Django

djangodjango-admindjango-formsdjango-models

I need a model field composed of a numeric string for a Django app I'm working on and since one doesn't exist I need to roll my own. Now I understand how "get_db_prep_value" and such work, and how to extend the Model itself (the django documentation on custom model fields is an invaluable resource.), but for the life of me I can't seem to figure out how to make the admin interface error properly based on input constraints.

How do I make the associated form field in the admin error on incorrect input?

Best Answer

Have a look at the Form and field validation section in the Django documentation, maybe that's what you're looking for?

You would have to make a new type of form field for your custom model field.