mirror of https://github.com/snachodog/mybuddy.git
Use `last()` instead of `latest()`
With `latest()`, an exception is thrown if there is one child in the database and no feeding entries.
This commit is contained in:
parent
843c7fc49b
commit
60cd90ca80
|
@ -46,7 +46,7 @@ def set_initial_values(kwargs, form_type):
|
|||
# Set initial type value for Feeding instance based on last type used.
|
||||
if form_type == FeedingForm and 'child' in kwargs['initial']:
|
||||
last_feeding = models.Feeding.objects.filter(
|
||||
child=kwargs['initial']['child']).latest('end')
|
||||
child=kwargs['initial']['child']).order_by('end').last()
|
||||
if last_feeding:
|
||||
kwargs['initial'].update({'type': last_feeding.type})
|
||||
|
||||
|
|
Loading…
Reference in New Issue