Context Problem in Blender 2.80 python module
Some things to check and look out for.


Expect context.window, context.screen etc to be None in headless
mode. 
If an operator works in the python console in blender then chances
are it needs no special window, screen or region for context.  AFAIK
the edit mode toggle operator only needs an editable object active.
Check the bpy module works in your python shell 

Recommend using myObj = context.object A new cube may not always have
the name "Cube" eg Cube in another language
The space member of context is context.space_data or from the area as area.spaces.active.


And the answer was, as supplied by the OP


  ...It seems, that the precise location where i do the import bpy is
  very important. My error was that I put import bpy at the top of my
  .py (prior to some Django getUserInput function). Therefore i strongly
  recommend to others working in Django or other python environments to
  always use import bpy DIRECTLY before your blender scripting. I have
  now also tried to run a more advanced script and it works!