Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by zero when opening summary without data #2

Closed
s1hofmann opened this issue May 2, 2020 · 1 comment
Closed

Division by zero when opening summary without data #2

s1hofmann opened this issue May 2, 2020 · 1 comment

Comments

@s1hofmann
Copy link

Error: ZeroDivisionError at /1/summary/

Steps to reproduce:

  • Follow setup guide
  • Have no sleep data
  • Click view -> summary

Stacktrace:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/1/summary/

Django Version: 3.0.5
Python Version: 3.7.3
Installed Applications:
['slogger.apps.SloggerConfig',
 'registration.apps.RegistrationConfig',
 'bootstrap4',
 'bootstrap_datepicker_plus',
 'crispy_forms',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "/Users/s1hofmann/Documents/git/besdd/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/s1hofmann/Documents/git/besdd/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/s1hofmann/Documents/git/besdd/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/s1hofmann/Documents/git/besdd/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/s1hofmann/Documents/git/besdd/venv/lib/python3.7/site-packages/django/contrib/auth/mixins.py", line 52, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/Users/s1hofmann/Documents/git/besdd/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/Users/s1hofmann/Documents/git/besdd/venv/lib/python3.7/site-packages/django/views/generic/list.py", line 157, in get
    context = self.get_context_data()
  File "/Users/s1hofmann/Documents/git/besdd/slogger/views.py", line 207, in get_context_data
    context["avg_sleep"] = functions.calculate_average(totals, "time")
  File "/Users/s1hofmann/Documents/git/besdd/slogger/functions.py", line 30, in calculate_average
    return total_sleep/total_days

Exception Type: ZeroDivisionError at /1/summary/
Exception Value: division by zero
@andreas-hofmann
Copy link
Owner

Whoops. That's what you get for not testing properly.
Fixed with 06f2f84.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants