Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Added default for app_label and model in contenttype query #39

Open
wants to merge 3 commits into
base: feature/django-1.9
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions jmbo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_template_names(self):

class ObjectList(ListView):
model = ModelBase
app_label = "jmbo"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't make it a class level attr - just use it as the second arg to kwargs.get.

This code looks weird in any case - it's very old, but I understand what you need to achieve. With jmbo-listing we're not using ObjectList much anymore.

template_name = "jmbo/object_list.html"
params = {}
view_modifier = DefaultViewModifier
Expand All @@ -58,8 +59,8 @@ class ObjectList(ListView):

def get_queryset(self):
qs = self.model.permitted.filter(
content_type__app_label=self.kwargs["app_label"],
content_type__model=self.kwargs["model"]
content_type__app_label=self.kwargs.get("app_label", self.app_label),
content_type__model=self.kwargs.get("model", self.model)
)

# Push self through view modifier
Expand Down