from django import forms

from .models import Review


class ReviewForm(forms.models.ModelForm):
    name = forms.CharField(
        max_length=30,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'Your Name',
                'class': 'form-control',
                }),
        )

    class Meta:
        model = Review
        fields = ['title', 'rating', 'text']
        widgets = {
            'title': forms.fields.TextInput(
                attrs={
                    'placeholder': 'Short Summary e.g. Awesome Product',
                    'class': 'form-control',
                    }),
            'text': forms.Textarea(
                attrs={
                    'placeholder': 'Your Review',
                    'class': 'form-control',
                    'rows': 5,
                    }),
        }

from django import forms

from .models import Review


class ReviewForm(forms.models.ModelForm):
    name = forms.CharField(
        max_length=30,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'Your Name',
                'class': 'form-control',
                }),
        )

    class Meta:
        model = Review
        fields = ['title', 'rating', 'text','product']
        widgets = {
            'title': forms.fields.TextInput(
                attrs={
                    'placeholder': 'Short Summary e.g. Awesome Product',
                    'class': 'form-control',
                    }),
            'text': forms.Textarea(
                attrs={
                    'placeholder': 'Your Review',
                    'class': 'form-control',
                    'rows': 5,
                    }),
        }

Add product field to ReviewForm
Add product field to ReviewForm

  from django import forms
  
  from .models import Review
  
  
  class ReviewForm(forms.models.ModelForm):
      name = forms.CharField(
          max_length=30,
          widget=forms.TextInput(
              attrs={
                  'placeholder': 'Your Name',
                  'class': 'form-control',
                  }),
          )
  
      class Meta:
          model = Review
-         fields = ['title', 'rating', 'text']
+         fields = ['title', 'rating', 'text','product']
          widgets = {
              'title': forms.fields.TextInput(
                  attrs={
                      'placeholder': 'Short Summary e.g. Awesome Product',
                      'class': 'form-control',
                      }),
              'text': forms.Textarea(
                  attrs={
                      'placeholder': 'Your Review',
                      'class': 'form-control',
                      'rows': 5,
                      }),
          }
  
Add product field to ReviewForm
## Code Before:
from django import forms

from .models import Review


class ReviewForm(forms.models.ModelForm):
    name = forms.CharField(
        max_length=30,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'Your Name',
                'class': 'form-control',
                }),
        )

    class Meta:
        model = Review
        fields = ['title', 'rating', 'text']
        widgets = {
            'title': forms.fields.TextInput(
                attrs={
                    'placeholder': 'Short Summary e.g. Awesome Product',
                    'class': 'form-control',
                    }),
            'text': forms.Textarea(
                attrs={
                    'placeholder': 'Your Review',
                    'class': 'form-control',
                    'rows': 5,
                    }),
        }

## Instruction:
Add product field to ReviewForm
## Code After:
from django import forms

from .models import Review


class ReviewForm(forms.models.ModelForm):
    name = forms.CharField(
        max_length=30,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'Your Name',
                'class': 'form-control',
                }),
        )

    class Meta:
        model = Review
        fields = ['title', 'rating', 'text','product']
        widgets = {
            'title': forms.fields.TextInput(
                attrs={
                    'placeholder': 'Short Summary e.g. Awesome Product',
                    'class': 'form-control',
                    }),
            'text': forms.Textarea(
                attrs={
                    'placeholder': 'Your Review',
                    'class': 'form-control',
                    'rows': 5,
                    }),
        }
