﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
497	Request DB API access to the validation information in the model	anonymous	Adrian Holovaty	"In the data model, there is validation information such as character field maximum length, which is used for form entry validation in the Admin interface.

However, this doesn't seem to be available from the DB API for validation:

e.g. Using the polls/choices example;

{{{
>>> from django.models.polls import polls, choices
>>> p = polls.get_object(pk=1)
>>> p.question = 'x'*300
>>> p.save()
Traceback (most recent call last):
...
ProgrammingError: ERROR:  value too long for type character varying(200)

UPDATE polls_polls SET question='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxK
>>>
}}}


It would be nice to have something like:

{{{
>>> polls.is_data_valid_for_field(data='x'*300, field=question)
False
>>> 
}}}

and/or

{{{
>>> polls.validation_data['question']
{'max_length':200, ... }

}}}

Perhaps this could be integrated with the Validators interface?"	enhancement	closed	Database layer (models, ORM)		normal	invalid			Unreviewed	0	0	0	0	0	0
