mirror of https://github.com/snachodog/mybuddy.git
Make sure there is at least one Feeding object before attempting to preset the type for a new entry.
This commit is contained in:
parent
382d106c28
commit
7c980150a4
|
@ -41,7 +41,7 @@ def set_default_feeding_type(kwargs):
|
||||||
instance = kwargs.get('instance', None)
|
instance = kwargs.get('instance', None)
|
||||||
if not kwargs.get('initial'):
|
if not kwargs.get('initial'):
|
||||||
kwargs.update(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({
|
kwargs['initial'].update({
|
||||||
'type': models.Feeding.objects.latest('end').type
|
'type': models.Feeding.objects.latest('end').type
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue