0

I have been using in generic views (CBVs)

def get_context_data(self, **kwargs):
    context = super().get_context_data(**kwargs)

but I've noticed that people here do:

context = super(ClassViewName,self).get_context_data(**kwargs)

is there is a difference ?

Mohamed Benkedadra
  • 1,964
  • 3
  • 21
  • 48

1 Answers1

2

The difference is python version supported syntax. In python 3 you would use

context = super().get_context_data(**kwargs)

while in python 2 you would use

context = super(ClassViewName,self).get_context_data(**kwargs)

this is true for any super method call

see: http://www.pythonforbeginners.com/super/working-python-super-function

polo
  • 1,352
  • 2
  • 16
  • 35