fix if there is no instance, it throws an error
This commit is contained in:
@@ -291,7 +291,8 @@ class ResolutionAdminForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
|
||||
bills = Bill.objects.filter(resolution=kwargs["instance"])
|
||||
resolution = kwargs.get("instance", None)
|
||||
bills = Bill.objects.filter(resolution=resolution)
|
||||
total = 0
|
||||
for elem in bills:
|
||||
total += elem.amount
|
||||
@@ -322,7 +323,8 @@ class WirefAdminForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
|
||||
bills = Bill.objects.filter(wiref=kwargs["instance"])
|
||||
wiref = kwargs.get("instance", None)
|
||||
bills = Bill.objects.filter(wiref=wiref)
|
||||
total = 0
|
||||
for elem in bills:
|
||||
total += elem.amount
|
||||
|
||||
Reference in New Issue
Block a user