0

Is there a way to use something like dynamic forms in Django? I don't mean something like django-dynamic-forms 0.5.1 where you can create forms in Admin.

enter image description here

Simple example:

So on the web page, I could choose, for example, state from drop down menu and then, right next to this drop down menu there would be another drop down menu where I could choose city (based on the first drop down menu).

The real problem:

In my project, there is a Translator which can be able to translate many languages with 3 possible levels ( like Native, Intermediate ... ).

When customer want's to get something translated, they have to fill the CreationJobForm - an here is a problem. It is possible that customer wants to translate some text into multiple languages - so he would just choose those languages.

But what if there is just one Translator speaking Chineese on Basic level and customer wants professional level - according to this situation, I can't just create a form with drop down menu - Language and drop down menu - Level, because the customer could be able to choose professional level which is not possible for us to translate.

So my point is that I would like to have a form in which customer could choose language and based on that language, he would be able to choose only those levels which are in our database. Then he could choose another language, then level etc.

Is it possible to make it work through Django forms?

Maybe, this approach would be simpler because you can prepare the form just once and you don't need to change the second drop down menu after filling the first.

enter image description here

user3620512
  • 39
  • 1
  • 8
  • 1
    I'm not sure if is possible with django-forms but is pretty easy with JavaScript (JQuery). – dquinonez Apr 14 '16 at 14:37
  • I'm not an expert but I think that it could be possible because you know all information before you render the page. I would appreciate any advice how to solve this problem/ – user3620512 Apr 14 '16 at 14:42
  • I don't have a clue how it would be done with JQuery since I don't know JS and don't know how to connect JS with Django. – user3620512 Apr 14 '16 at 14:45
  • I think this question is related to yours. http://stackoverflow.com/questions/26975708/django-cms-multi-level-dropdown-menu – dquinonez Apr 14 '16 at 14:47
  • other one https://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic – dquinonez Apr 14 '16 at 14:50
  • I think what you need is to take a look at the https://github.com/digi604/django-smart-selects – durdenk Apr 14 '16 at 17:00
  • I've seen that before but I'm not sure whether it is good to change my models... – user3620512 Apr 14 '16 at 17:27
  • You would connect jQuery and Django through Ajax, and something like django-rest-framework – Aaron Lelevier Apr 14 '16 at 20:10
  • Why don't you think about using https://docs.djangoproject.com/en/1.9/topics/i18n/translation/, to handle translate in your project, as for the widget you want to build, read this http://django-autocomplete-light.readthedocs.org/en/master/#, it will help you build custom widget for the application. – copser Apr 15 '16 at 18:01

0 Answers0