﻿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
13606	admin raw_id_fields fail to check against non-numerical input	petrikuittinen@…	nobody	"Inputting a non-numerical value in a foreign key field using raw_input_fields produces a ValueError exception in django admin.
E.g write ""wer"" to any foreign key field, which has been declared with raw_input_fields fails:

{{{
Django Version:	1.2.1
Exception Type:	ValueError
Exception Value:	
invalid literal for int() with base 10: 'wer'
}}}


Using Django 1.2-beta I was able to fix this bug by simply appending these two lines to
django/contrib/admin/widgets.py label_for_value()-function:

    
{{{
def label_for_value(self, value):
        key = self.rel.get_related_field().name
        try: 
            obj = self.rel.to._default_manager.using(self.db).get(**{key: value})
        except self.rel.to.DoesNotExist: 
            return ''
        # simple fix  
        except ValueError:
            return ''
        # end of fix
        return '&nbsp;<strong>%s</strong>' % escape(truncate_words(obj, 14))
}}}


Now in Django 1.2.1 this fix unfortunately doesn't work."		closed	contrib.admin	1.2		duplicate			Unreviewed	1	0	1	0	0	0
