Custom JS for RadioSelect inlines in Django admin -


here working example on adding custom js code (any html indeed) each 1 of inlines: http://djangosnippets.org/snippets/1261/

but cannot reproduce radioselect type fields in admin.

model model.py:

class work(models.model):     client = models.foreignkey(client)      image = 'im'     video = 'vi'     content_type = (         (image, 'image'),         (video, 'video'),     )      content_type = models.charfield(max_length=2,                                     choices=content_type,                                     default=image) 

and admin.py:

class workinline(admin.tabularinline):     fields = ('content_type',)     radio_fields = {"content_type": admin.vertical}     model = work 

i can't figure out how override render() radio_fields (like it's done textinput in example above) inject code them. or may there easier way?

thanks help.

  1. you should call file since forms.py, should create class this:

    class workform(forms.modelform):      class meta:          model = work      def __init__(self, *args, **kwargs):          super(workform, self).__init__(*args, **kwargs)          self.fields['content_type'].widget = colorpickerwidget() 
  2. don't forget import widget


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -