jazzband / django-smart-selects

chained and grouped selects for django forms
https://django-smart-selects.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.1k stars 348 forks source link

[idea] : Adding kw/arg 'display_model_col' to ChainedForeignKey et al. #343

Open pareshpandit opened 2 years ago

pareshpandit commented 2 years ago

Hello folks!

First of all, thank you all so much for this amazing project - simple does it! :)

From my recent experience (or lack thereof), I felt the need to call a particular column from a model when loading it as a related/dependent dropdown in a form, using ChainedForeignKey.

Basically, if we could have an kw/arg that shall tell dictate that the form rendering use a column named so and so, when displaying the dropdown on the frontend, for a particular field (from its model table).

For example, it presently defaults to the 'name' column of a Model, I have observed. However, I would like to take it to the 'name_ascii' column of my tables.

This is because, in my DB tables, the name column contains "child, parent, grandparent" kind of entry in a three-tiered chain. Now, This creates repetition on the form, and of course, in its entries too. Thus, I would like to control that the singular name (self name only) column is picked for display, and thence posting.

I hope that you also find this worth implementing, and that we might have it available sometime soon. Have a nice day! :)