title: Django - Many to Many Model Returning None
body: <p>Long time listener, first time poster. Hoping to get some help with my models issue.</p>
  
  <p>I'm having trouble with my many to many relationship. When I submit a form, I want to have my user's info associated with the post that they create. I'm using a many to many because I will have an additional feature where other users can join in on that same trip.</p>
  
  <p>Currently my data for my Trip tables creates fine, but my user isn't being linked to the Trip id so I can't render out their name on the template.</p>
  
  <p>Below is my code. Appreciate any help!
  Cheers</p>
  
  <p>Here are my models.py:</p>
  
  <pre><code>class User(models.Model):
      name = models.CharField(max_length=45)
      username = models.CharField(max_length=255)
      password = models.CharField(max_length=255)
      created_at = models.DateTimeField(auto_now_add=True)
      updated_at = models.DateTimeField(auto_now=True)
      objects = UserManager()
  
  class Trip(models.Model):
      destination = models.CharField(max_length=45)
      description = models.CharField(max_length=255)
      datefrom = models.CharField(max_length=255)
      dateend = models.CharField(max_length=255)
      user = models.ManyToManyField(User)
      created_at = models.DateTimeField(auto_now_add=True)
      updated_at = models.DateTimeField(auto_now=True)
  </code></pre>
  
  <p>Here is my views.py:</p>
  
  <pre><code>def travels(request):
      user = User.objects.get(id=request.session['logged_user'])
      all_trips = Trip.objects.all().order_by('-id')
      user_trips = Trip.objects.filter(user=request.session['logged_user'])
      context = {
          "user_trips": user_trips,
          "all_trips": all_trips,
          "user": user,
      }
      return render(request, 'belt_exam/travels.html', context)
  
  def addtrip(request):
      user_id = request.session['logged_user']
      createdtrip = Trip.objects.create(destination=request.POST['destination'], description=request.POST['description'], datefrom=request.POST['datefrom'], dateend=request.POST['dateend'])
      createdtrip.user.add(User.objects.get(id=user_id))    
      return redirect('/travels')
  </code></pre>
  
  <p>Here's my template:</p>
  
  <pre><code>{% for alltrip in all_trips.all %}
      &lt;tr&gt;
          &lt;td&gt;{{alltrip.name}}&lt;/td&gt;
          &lt;td&gt;&lt;a href="travels/destination/{{alltrip.id}}"&gt;{{alltrip.destination}}&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;{{alltrip.datefrom}}&lt;/td&gt;
          &lt;td&gt;{{alltrip.dateend}}&lt;/td&gt;
          &lt;td&gt;
          &lt;form class="" action="travels/destination/{{alltrip.id}}" method="POST"&gt;
          {% csrf_token %}
          &lt;input type="submit" value="Join"&gt;
          &lt;/form&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  {% endfor %}
  </code></pre>