title: How to implement PUT method in Django
body: <p>How can I enable the user to generate only one instance of an object “bet” with a POST method and modify it through a PUT method (for example)</p>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class BetForm(forms.ModelForm):
      team1_score = forms.IntegerField(min_value=0, max_value=15)
      team2_score = forms.IntegerField(min_value=0, max_value=15)
      match = forms.ModelChoiceField(queryset=Match.objects.only('id'))
  
      class Meta:
          model = Bet
          fields = ('team1_score', 'team2_score', 'match')
  </code></pre>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Bet(models.Model):
      match = models.ForeignKey(Match, on_delete=models.CASCADE, related_name='+')
      team1_score = models.PositiveIntegerField(default=0)
      team2_score = models.PositiveIntegerField(default=0)
  
      def __str__(self):
          return (str(self.match))
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>    def post(self, request):  
          form = BetForm(request.POST)
          if form.is_valid():
              form.save()
              team1_score = form.cleaned_data.get('team1_score')
              team2_score = form.cleaned_data.get('team2_score')
              match = form.cleaned_data.get('match')
              form = BetForm()
              return redirect ('home')
          args = {'form': form, 'team1_score': team1_score, 'team2_score': team2_score, 'match': match}
          return render(request, self.template_name, args)
  </code></pre>