I have the following example and I don't know how to set a validation error for each row in admin interface:

> 
> refer to # add validation error for that row in forms.py
> 
> 
> 

models.py:

```
from django.db import models
from django.core.exceptions import ValidationError

class Foo(models.Model):
   name = models.CharField("Name", blank=True, max_length=300)

class Bar(models.Model):
   name = models.CharField("Name", blank=True, max_length=300)
   foo = models.ForeignKey('Foo', verbose_name='Foo')

```

admin.py

```
from django.contrib import admin
from .models import *
from .forms import *

class BarInline(admin.TabularInline):
    model = Bar
    formset = BarInlineFormset

@admin.register(Foo)   
class FooAdmin(admin.ModelAdmin):
    model = Foo
    inlines = [BarInline,]

```

forms.py

```
from django.db import models
from django import forms
from django.core.exceptions import ValidationError

class BarInlineFormset(forms.models.BaseInlineFormSet):
    def clean(self):
        data = self.cleaned_data
        valid = True
        for item in data:
            if not item:
                break;
            if not item['name'].startswith('Bar'):
                valid = False
                # add validation error for that row

        if not valid:
            raise ValidationError('Form is not valid.')

        return data

```

> 
> P.S. I'm using Django 1.8.x and Python 3.4
> 
> 
>