2👍
✅
You can override get_context_data to pass extra context:
...
def get_context_data(self, **kwargs):
context = super(ItemCreate, self).get_context_data(**kwargs)
context['storage_item'] = StorageItem.objects.get(pk=self.kwargs['pk'])
return context
0👍
Why not simply do the following:
class StorageItemTransactionAddView(View):
def post(self, request, pk):
storage_item = StorageItem.objects.get(pk=pk)
...
return render(request, 'myapp/index.html', {'object': storage_item})
Now in your template, you can do the following:
<h1>{{ object.name }}</h1>
Hope it helps
Source:stackexchange.com