1👍
get_context_data
is a method on the parent class. If you override it, you still need to call the parent method which is what adds the form to the context. You do this by calling super()
inside your own method, to obtain the context data, and then add your own:
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['prb'] = Problem.objects.select_related()
return context
Refer to the documentation on adding extra context to see how you should use get_context_data
.
0👍
This worked for me in a similar scenario
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
prb = Problem.objects.select_related()
context.update({'prb': prb})
return context
- [Answered ]-How to run django celery with SQS?
- [Answered ]-Login with facebook: django-allauth
- [Answered ]-How to override Django-CMS templates
- [Answered ]-Django rest framework serializer with extra field
- [Answered ]-How to setup source-folders for Django in intellij python-project? (Python-Plugin)
Source:stackexchange.com