Opened 3 years ago

Last modified 3 years ago

#33035 closed New feature

Autocomplete and populating Subcategories based on selected Categories (Admin and Forms) — at Version 2

Reported by: Jon Levischi Owned by: Jon Levischi
Component: Forms Version: 3.2
Severity: Normal Keywords: autocomplete_fields, limit_choices_to
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description (last modified by Jon Levischi)

A combination of the recently implemented "autocomplete_fields" with dynamic "limit_choices_to" that actually works on Foreign AND ManyToMany fields both on Admin site and Custom Forms.

class Project
    categories = M2M [having "Cat A", "Cat B", "Cat C", "Cat D", etc.]
    subcategories = M2M [having "Sub A1", "Sub A2", "Sub B1", "Sub B2", "Sub C1", "Sub C2", etc.]

When selecting Cat A in the category it would populate subcategory limiting options to "Sub A1", "Sub A2", "Sub C1", "Sub C2", based on their parents, but not "Cat B" nor "Cat D" children).

I know this is possible using Ajax, django-autocomplete-light or similar, but it's so frequently used that I think it makes sense to be included in Django itself.

Thank you!

Change History (2)

comment:1 by Jon Levischi, 3 years ago

Description: modified (diff)
Owner: changed from nobody to Jon Levischi
Status: newassigned

comment:2 by Jon Levischi, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top