You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the amount of customization offered on autocompletable objects grows, it seems useful to organize the customizable attributes and methods into a single object. This idea grew out of the discussion in #47.
Currently you can customize autocomplete properties like so:
If implemented now, #36 would add yet another classmethod to the mix. To clean this up and keep it more organized, we'll introduce a new AutocompleteManager type. The default autocomplete manager would look something like this:
classSearchingAutocompleteManager(AutocompleteManager):
defsearch(self, model_class: type, value: str) ->QuerySet:
returnmodel_class.objects.search(value)
# Notice that no `create` method is specified by default,# but can be specified on a subclassdefcreate(self, model_class: type, value: str) ->models.Model:
returnmodel_class.objects.create(title=value)
deflabel(self, obj: models.Model) ->str:
returnobj.__unicode__()
You would register a particular manager with a particular target either declaratively:
@harrislapiroff this is looking really good. I think a major benefit of breaking things off into a separate component like this is: It could give developers flexibility to list the same model in different ways.
For example:
Include product codes in an admin-facing list, but only show product names in a public-facing one
Include draft items in an admin-facing list, but not a public-facing one
Show the draft_title in an admin-facing list, but title in a public-facing one
How difficult do you think it would be to add support for this?
As the amount of customization offered on autocompletable objects grows, it seems useful to organize the customizable attributes and methods into a single object. This idea grew out of the discussion in #47.
Currently you can customize autocomplete properties like so:
If implemented now, #36 would add yet another
classmethod
to the mix. To clean this up and keep it more organized, we'll introduce a newAutocompleteManager
type. The default autocomplete manager would look something like this:A subclass of it might look like
You would register a particular manager with a particular target either declaratively:
or with a class decorator:
The text was updated successfully, but these errors were encountered: