title: Django. Star rating multiple form displayed in a grid view not working
body: <p>I've got a little problem. I have a page that is used to rate ski resorts. They are displayed in a grid view and each resort has a star rating form beneath.
  The problem is that only the first item in the grid can be rated.
  I tried to assign each form an unique id but that didn't work.</p>
  <p>Here is the code:</p>
  <pre><code>class AddRatingForm(forms.ModelForm):
      class Meta:
      model = ResortUserRating
          fields = '__all__'
  
          widgets = {
              'resort_rating': forms.RadioSelect()
          }
  
      def __init__(self, pk,  *args, **kwargs):
          super(AddRatingForm, self).__init__(*args, **kwargs)
          self.pk = pk
          self.fields['user'].initial = self.pk
  
      def clean(self):
          return self.cleaned_data
  
  
  {% for resort in dashboard_resorts %}
  
                      &lt;div class = &quot;grid-item&quot;&gt;
                          {% if resort.img %}
                              &lt;img class=&quot;card-img-top&quot; src=&quot;{{resort.img.url}}&quot;  alt 
                              =&quot;Card image cap&quot; height=&quot;300px&quot; width=&quot;380px&quot;&gt;
                          {% endif %}
                          &lt;p&gt; &lt;b&gt;{{resort.name|upper}} &lt;/b&gt;&lt;/p&gt;
                          &lt;p&gt; &lt;b&gt;{{resort.id|upper}} &lt;/b&gt;&lt;/p&gt;
  
                          &lt;form method=&quot;post&quot; action = &quot;{% url 'aplicatie2:rating' %}&quot;&gt;
                              {% csrf_token %}
                              &lt;input type = &quot;hidden&quot; name = &quot;user&quot; value = &quot;{{user.id}}&quot;&gt;
                              &lt;input  type = &quot;hidden&quot; name = &quot;resorts&quot; value = &quot; 
                              {{resort.id}}&quot;&gt;
  
                              &lt;div class=&quot;rate&quot;&gt;
                                  &lt;input type=&quot;radio&quot; name=&quot;resort_rating&quot; id=&quot;rating1&quot; 
                                   value=&quot;1&quot; required /&gt;&lt;label for=&quot;rating1&quot; title=&quot;1&quot;&gt; 
                                  &lt;/label&gt;
                                  &lt;input type=&quot;radio&quot; name=&quot;resort_rating&quot; id=&quot;rating2&quot; 
                                   value=&quot;2&quot; required /&gt;&lt;label for=&quot;rating2&quot; title=&quot;2&quot;&gt; 
                                   &lt;/label&gt;
                                  &lt;input type=&quot;radio&quot; name=&quot;resort_rating&quot; id=&quot;rating3&quot; 
                                      value=&quot;3&quot; required /&gt;&lt;label for=&quot;rating3&quot; title=&quot;3&quot;&gt; 
                                  &lt;/label&gt;
                                  &lt;input type=&quot;radio&quot; name=&quot;resort_rating&quot; id=&quot;rating4&quot; 
                                  value=&quot;4&quot; required /&gt;&lt;label for=&quot;rating4&quot; title=&quot;4&quot;&gt; 
                                  &lt;/label&gt;
                                  &lt;input type=&quot;radio&quot; name=&quot;resort_rating&quot; id=&quot;rating5&quot; 
                                  value=&quot;5&quot; required /&gt;&lt;label for=&quot;rating5&quot; title=&quot;5&quot;&gt; 
                                  &lt;/label&gt;
                                  &lt;/div&gt;
                              &lt;br&gt;
                              &lt;input type = &quot;submit&quot; class = &quot;btn btn-primary&quot; value = 
                              &quot;submit&quot;&gt;
                              {{form.errors}}
                          &lt;/form&gt;
                      &lt;/div&gt;
      {% endfor %}
  </code></pre>