title: Internal Server Error connecting to Django database
body: <p>I have a connection function built to write data to my database.
  Here's the connect function from views.py</p>
  
  <pre><code>
  def _parse_body(body):
      body_unicode = body.decode("utf-8")
      return json.loads(body_unicode)
  
  @csrf_exempt
  def connect(request):
      body = _parse_body(request.body)
      connection_id = body['connectionId']
      connect = Connection(connection_id=connection_id)
      connect.save()
      return JsonResponse({"message":"connect successfully"}, status=200)
  </code></pre>
  
  <p>And the models</p>
  
  <pre><code>from django.db import models
  
  # Create your models here.
  
  class Connection(models.Model):
      connection_id = models.CharField(max_length=255)
  
  class ChatMessage(models.Model):
      username = models.CharField(max_length=50)
      message = models.CharField(max_length=400)
      timestamp = models.CharField(max_length=100)
  </code></pre>
  
  <p>Testing the connect api on postman and with curl returns a 500 internal server error like this:
  <a href="https://i.stack.imgur.com/dCjmh.png" rel="nofollow noreferrer">connect testing on postman</a></p>
  
  <p>Here's also the stacktrace:
  <a href="https://i.stack.imgur.com/AxEX0.png" rel="nofollow noreferrer">stacktrace</a></p>