Answer the question
In order to leave comments, you need to log in
How to get sum of all inline fields in django?
There are two classes:
class Foo(models.Model):
...
my_max_total = models.IntegerField()
class Bar(models.Model):
total = models.IntegerField()
my_foo = models.ForeignKey(Foo)
class BarInline(admin.TabularInline):
model = Bar
class FooAdmin(admin.ModelAdmin):
inlines = (BarInline, )
Answer the question
In order to leave comments, you need to log in
Set a custom admin form and override its clean method. In this method, check everything you need and in case of an error, throw the forms.ValidationError exception.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question