Dynamic model choice field on a django cms plugin

101 views
Skip to first unread message

bixly.je...@gmail.com

unread,
Feb 21, 2017, 8:23:13 PM2/21/17
to django CMS developers
Hi

I'm currently working on a django cms plugin with a model choice field dependent on another field in the change form. What i'm doing now via ajax is that, when the trigger field is selected, the dependent model choice field is updated via ajax to change the choices in the select field. However on submit, of the form, i'm encountering this error

“Select a valid choice. That is not one of the available choices.”

I did some digging in stack overflow and found a similar issue although this one is for a regular django page

http://stackoverflow.com/questions/28339713/while-using-ajax-with-django-form-getting-error-select-a-valid-choice-that-is

Based on the link above, i should update model choice field in the form of the plugin itself depending on the value of the trigger field which i will get from request.POST

How do i go about doing this for a django cms plugin? Which method of the cms plugin should I override? I'm assuming its a method in the plugin's CMSPluginBase class but i'm not sure exactly what method to override and also how will i get the current form being used by my plugin so i could override that in the said method so that i could return my form data

Thanks

Reply all
Reply to author
Forward
0 new messages