1π
β
In the first example, the language is evaluated when class is loaded at first time. Try for example this:
def a(x=[]):
x.append(1)
print x
a()
a()
a()
a()
result will be:
[1]
[1, 1]
[1, 1, 1]
[1, 1, 1, 1]
EDIT:
you could do something like this:
class LandingPageOverview(ListView):
model = LandingPage
context_object_name = 'landingpages'
template_name = 'landingpage/overview.html'
@property
def queryset(self):
return LandingPage.objects.filter(language=translation.get_language())
and use it like you want:
l = LandingPageOverview()
l.queryset
π€Pavel Reznikov
Source:stackexchange.com