Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33035 closed New feature (needsinfo)

Autocomplete and populating Subcategories based on selected Categories (Admin and Forms)

Reported by: Jon Levischi Owned by:
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" (awesome btw!) 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 (6)

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)

comment:3 by Jon Levischi, 3 years ago

Description: modified (diff)

comment:4 by Carlton Gibson, 3 years ago

Triage Stage: UnreviewedAccepted

Hi Jon — Sounds like a nice feature if it's feasible. I'm not sure it'll be quite Easy Pickings but since you've assigned yourself, very happy to have a look at one you come up with. Thanks!

comment:5 by Jon Levischi, 3 years ago

Owner: Jon Levischi removed
Status: assignednew

comment:6 by Mariusz Felisiak, 3 years ago

Resolution: needsinfo
Status: newclosed

Jon unassigned this ticket from themself, so closing as needsinfo, unless someone provides PoC.

Last edited 3 years ago by Mariusz Felisiak (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top