@@ -55,11 +47,27 @@ class RoomAutocomplete(AutocompleteViewMixin):
# Suppose we have a dorm named Dorm, a building name B, and rooms from 001 - 999
# Comments explain what we try to match
self.query_set=self.query_set.annotate(
full_name=Concat("building__name",Value(" "),"name"),# Match when the user searches "B 001"
full_name=Concat(
"building__name",Value(" "),"name"
),# Match when the user searches "B 001"
full_name_stuck=Concat("building__name","name"),# Match "B001"
dorm_name=Concat("building__dormitory__name",Value(" "),"name"),# Match "Dorm 001"
dorm_full_name=Concat("building__dormitory__name",Value(" "),"building__name",Value(" "),"name"),# Match "Dorm B 001"
dorm_full_colon_name=Concat("building__dormitory__name",Value(" : "),"building__name",Value(" "),"name"),# Match "Dorm : B 001" (see Room's full_name property)
dorm_name=Concat(
"building__dormitory__name",Value(" "),"name"
),# Match "Dorm 001"
dorm_full_name=Concat(
"building__dormitory__name",
Value(" "),
"building__name",
Value(" "),
"name",
),# Match "Dorm B 001"
dorm_full_colon_name=Concat(
"building__dormitory__name",
Value(" : "),
"building__name",
Value(" "),
"name",
),# Match "Dorm : B 001" (see Room's full_name property)
).all()
ifself.q:
...
...
@@ -89,8 +97,7 @@ class BuildingAutocomplete(AutocompleteViewMixin):