Skip to content

Commit

Permalink
Make sure there is at least one Feeding object before attempting to p…
Browse files Browse the repository at this point in the history
…reset the type for a new entry.
  • Loading branch information
cdubz committed Apr 7, 2018
1 parent 382d106 commit 7c98015
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set_default_feeding_type(kwargs):
instance = kwargs.get('instance', None)
if not kwargs.get('initial'):
kwargs.update(initial={})
if instance is None and models.Feeding.objects.latest('end'):
if instance is None and models.Feeding.objects.count() > 0:
kwargs['initial'].update({
'type': models.Feeding.objects.latest('end').type
})
Expand Down

0 comments on commit 7c98015

Please sign in to comment.