Django-autocomplete-light: Dependant autocomplete

Created on 15 Feb 2018  路  5Comments  路  Source: yourlabs/django-autocomplete-light

Hello. I've found this great video overview of DAL and installed demo-project, but i can't find dependant autocomplete in the admin.

Here is the example of it in the video: https://youtu.be/fJIHiqWKUXI?t=333

Can you please guide me to the right direction?

Thanks

question

Most helpful comment

@Senpos shameless plug with a complicated example: this thing in my project https://github.com/mpasternak/django-bpp/blob/dev/src/bpp/admin/praca_habilitacyjna.py#L43 will forward the field "autor" of every row in the the _inline_ form to the widget. "Forward" as in "get the value using javascript and pass it as JSon".

I'm not sure where that example did go. Have more questions?

All 5 comments

It's in the tutorial: http://django-autocomplete-light.readthedocs.io/en/master/tutorial.html#filtering-results-based-on-the-value-of-other-fields-in-the-form

@jpic thanks for sharing. Sadly, it looks too complicated for me at the moment. Don't you have that good old City -> Country example somewhere?

@Senpos

The concept is the following: DAL JS picks a field value that you choose and passes it as an additional parameter to the request to autocomplete view. So all you have to do is specify which field value do you want to pass (forward parameter for widget) to the view and handle it on server side (in the view).

There are some examples in the test_project folder in this repo, but unfortunately they are a little bit more abstract that city->country. The simplest one is linked_data. There are also rename_forward and forward_different_fields examples to demonstrate more advanced use of forwarding.

@Senpos shameless plug with a complicated example: this thing in my project https://github.com/mpasternak/django-bpp/blob/dev/src/bpp/admin/praca_habilitacyjna.py#L43 will forward the field "autor" of every row in the the _inline_ form to the widget. "Forward" as in "get the value using javascript and pass it as JSon".

I'm not sure where that example did go. Have more questions?

@jpic @gagarski @mpasternak
Thanks for help and useful links, will take a look at all of these stuff! 馃憤

Will mark this topic as closed now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandenhall picture brandenhall  路  9Comments

raratiru picture raratiru  路  4Comments

bemall picture bemall  路  8Comments

dotmobo picture dotmobo  路  7Comments

VagnerNico picture VagnerNico  路  4Comments