#13606: admin raw_id_fields fail to check against non-numerical input
--------------------------------------+-------------------------------------
 Reporter:  petrikuitti...@yahoo.com  |       Owner:  nobody    
   Status:  new                       |   Milestone:            
Component:  django.contrib.admin      |     Version:  1.2       
 Keywords:                            |       Stage:  Unreviewed
Has_patch:  0                         |  
--------------------------------------+-------------------------------------
 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.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13606>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to