TypeError django context using custom class <p>I am new to python and django, and I am trying to pass a class to my <code>RequestContext</code> in a template. So I have this code:</p> <pre><code>context = RequestContext(request, { 'test' : myClass, }) </code></pre> <p>And myClass is an instance of this:</p> <pre><code>class ajax_user_session(): user_model = None user_settings = None time_login = datetime.datetime.now() </code></pre> <p>Both <code>user_model</code> and <code>user_settings</code> are classes derived from django's <code>models.Model</code> (assigned before creating and using the context class). I get the following error:</p> <pre><code>TypeError at /settings &lt;playground.ajax_processing.ajax_user_session instance at 0x263fab8&gt; is not JSON serializable </code></pre> <p>Does somebody know how to solve this, please? I can assign "normal" variables like strings, integers, but I don't want to add several things to the dictionary, I just want to use one big class.</p> <p>Thank you.</p>