In my function, if a dictionary exists (passed in as a parameter) then add another dictionary to it, or else use it as the dictionary. (here context is the relevant dictionary)
def some_view(request, form_class, template, success_url, context=None):
..........
if context is not None:
context.update({'form': form})
else:
context = {'form': form}
return render(request, template, context)
This works fine but using
context = context.update({'form': form}) if context is not None else {'form': form}
fails for some reason as context is return as None?
contextis None, how can you callupdateon it?context.update()returnsNonebut you're using it in an assignment