Skip to content

Commit e05cc49

Browse files
committed
Make objects ListView work for models
1 parent 2442976 commit e05cc49

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bolt/views/objects.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ class ListView(TemplateView):
190190
context_object_name = "objects"
191191

192192
def get(self) -> HttpResponse:
193-
self.objects = self.get_queryset()
193+
self.objects = self.get_objects()
194194
return super().get()
195195

196-
def get_queryset(self): # Intentionally untyped... subclasses must override this.
196+
def get_objects(self):
197197
raise NotImplementedError(
198-
f"get_queryset() is not implemented on {self.__class__.__name__}"
198+
f"get_objects() is not implemented on {self.__class__.__name__}"
199199
)
200200

201201
def get_context(self) -> dict:
@@ -222,8 +222,8 @@ def get_template_names(self) -> list[str]:
222222

223223
# The least-specific option is the default <app>/<model>_detail.html;
224224
# only use this if the object in question is a model.
225-
if hasattr(self.objects, "_meta"):
226-
object_meta = self.objects._meta
225+
if hasattr(self.objects, "model") and hasattr(self.objects.model, "_meta"):
226+
object_meta = self.objects.model._meta
227227
names.append(
228228
f"{object_meta.package_label}/{object_meta.model_name}{self.template_name_suffix}.html"
229229
)

0 commit comments

Comments
 (0)