title: How to get Checkbox Select Multiple for profile page
body: <p>Beginner here in Django.</p>
  <p><strong>Goal:</strong>
  I would like to get a multiple checkbox selection for favorite categories and save those in
  the database.</p>
  <p><strong>Problem</strong>
  Right now I have a profile form and model, and the CheckboxSelectMultiple widget is not working like I want it to work. The categories are stored in another model which I reference in the user profile.</p>
  <pre><code># # # # user/forms/profile_form.py
  class ProfileForm(ModelForm):
      class Meta:
          model = Profile
          exclude = [ 'id', 'user']
          widgets = {
              'favourite_categories': widgets.CheckboxSelectMultiple(attrs={'class': 'form-control'}),
              'profile_picture': widgets.TextInput(attrs={'class': 'form-control'})
          }
  
  
  # # # # user/models.py
  class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      first_name = models.CharField(max_length=200, blank=True)
      last_name = models.CharField(max_length=200, blank=True)
      favorite_categories = models.ManyToManyField(Category, blank=True)
      profile_image = models.CharField(max_length=200, null=True, blank=True)
  
  
  # # # # user/views.py
  @ login_required
  def profile(request):
      user_profile = Profile.objects.filter(user=request.user).first()
      if request.method == 'POST':
          form = ProfileForm(instance=user_profile, data=request.POST)
          if form.is_valid():
              user_profile = form.save(commit=False)
              user_profile.user = request.user
              user_profile.save()
              return redirect('profile')
      return render(request,
                    'user/profile.html',
                    context={&quot;form&quot;: ProfileForm(instance=user_profile)})
  
  
  # # # # templates/user/profile.html
  &lt;div class=&quot;shadow p-4 mb-5 mx-5 bg-body rounded&quot;&gt;
      &lt;form class=&quot;form form-horizontal&quot; method=&quot;post&quot;&gt;
          {% csrf_token %}
          {{ form|crispy }}
          &lt;input type=&quot;submit&quot; class=&quot;btn btn-primary&quot; value=&quot;Update&quot; /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  <p>The output of this can be seen in the picture.
  <a href="https://i.stack.imgur.com/pV1Iw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pV1Iw.png" alt="Output of the current code." /></a></p>
  <p><strong>PS. I also don't know how to use ImageField for inserting a profile image. I am using a google cloud database and the ImageField needs the variable upload_to, which specifies where the image will be uploaded to. I would like to store the image on the cloud database as all other data is.</strong></p>