title: Try to pass the initial data in the form with the field ManyToMany
body: <p>My problem is that I can not save the form. I think the problem lies in the <code>event</code> field in the <code>Register</code> model.
  I do not want the user to choose an Event from the list, I want it to happen automatically, hence the code: <code>form.cleaned_data['event'] = kwargs['pk']</code>
  This part of code <code>kwargs['pk']</code> is from url.</p>
  
  <p>Please any hint if this is good approch to dealing with forms and hint to solve my problem. Below is my code.</p>
  
  <p>Thanks :)</p>
  
  <p>Models:</p>
  
  <pre><code>class Event(models.Model):
      title = models.CharField(max_length=500)
      date = models.DateField()
      text = models.TextField()
      image = FilerImageField(null=True, blank=True)
      flag = models.ForeignKey(Flag)
      free_places = models.IntegerField()
  
      class Meta:
          ordering = ['-date']
  
      def __str__(self):
          return self.title
  
      @property
      def slug(self):
          return slugify(self.title)
  
      def get_absolute_url(self):
          return reverse('events:detail', args=[self.slug, self.id])
  
  
  class Register(models.Model):
      event = models.ForeignKey(Event)
      first_name = models.CharField(max_length=30)
      last_name = models.CharField(max_length=30)
      company = models.CharField(max_length=30, blank=True)
      street = models.CharField(max_length=50, blank=True)
      post_code = models.CharField(max_length=30, blank=True)
      city = models.CharField(max_length=30, blank=True)
      email = models.EmailField()
      phone_number = models.IntegerField()
  
      def __str__(self):
          return self.first_name
  
      def get_event_name(self):
          return self.event
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>class EventDetailView(DetailView, ModelFormMixin):
      model = models.Event
      form_class = forms.RegisterForm
  
      def get_success_url(self):
          return reverse('events:list')
  
      def post(self, request, *args, **kwargs):
          form = self.get_form()
          print(kwargs['pk'])
          print(self.form_class)
          if form.is_valid():
              print(form.cleaned_data['event'])
              form.cleaned_data['event'] = kwargs['pk']
              form.save()
              return self.form_valid(form)
          else:
              return self.form_invalid(form)
  </code></pre>
  
  <p>My form:</p>
  
  <pre><code>class RegisterForm(ModelForm):
      class Meta:
          model = models.Register
          fields = ('event', 'first_name', 'last_name', 'company', 'street', 'post_code', 'city', 'email', 'phone_number',)
  </code></pre>
  
  <p>My template:</p>
  
  <pre><code>{% extends 'base.html' %}
  
  {% block content %}
      &lt;ul&gt;
          &lt;h1&gt;Detail page:&lt;/h1&gt;
          &lt;li&gt;{{ object.title }}&lt;/li&gt;
          &lt;li&gt;{{ object.text }}&lt;/li&gt;
          &lt;li&gt;{{ object.date }}&lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;form method="post"&gt;
          {% csrf_token %}
          {{ form.as_p }}
          &lt;input type="submit" value="Submit" /&gt;
      &lt;/form&gt;
  
  {% endblock content %}
  </code></pre>