Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKayla Johnson
1,798 Pointssuper() takes at least 1 argument (0 given)
The video mentions using the following: def get_context_data(self, kwargs): context = super().get_context_data(kwargs)
But this doesn't work. I'm using Python 2.7 and I get the error that it needs an argument. What does this need to look like?
2 Answers
Kenneth Love
Treehouse Guest TeacherLegacy Python required you to specify the class and the instance. context = super(ClassName, self).get_context_data(**kwargs)
(you'll need to put your class name in there where it says ClassName
). All that extra code is yet one more reason to upgrade to modern Python.
Aditya Prakarsa
39,803 Pointscontext = super(HomeView, self).get_context_data(**kwargs)
instead of
context = super().get_context_data(**kwargs)
Kayla Johnson
1,798 PointsKayla Johnson
1,798 PointsI see, thank you. Unfortunately I took on a project for a client and they are using Python 2.7.