DjangoGirls / djangogirls

Website for DjangoGirls.org
http://djangogirls.org/
BSD 3-Clause "New" or "Revised" License
460 stars 281 forks source link

AttributeError: 'str' object has no attribute 'year' #644

Open sentry-io[bot] opened 3 years ago

sentry-io[bot] commented 3 years ago

Sentry Issue: DJANGO-GIRLS-WEBSITE-4

AttributeError: 'str' object has no attribute 'year'
(1 additional frame(s) were not displayed)
...
  File "django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "core/views.py", line 64, in event
    {'city': event.city, 'page_url': page_url, 'past': event.date <= now_approx}
  File "functools.py", line 105, in _ge_from_lt
    op_result = self.__lt__(other)
  File "django_date_extensions/fields.py", line 85, in __lt__
    return (self.year, self.month, self.day) < (other.year, other.month, other.day)

This is the code causing this trace is from core/views.py lines 60 - 64. We have had this error for a while. Thought it had been fixed by upgrading Python version.


    if not (event.is_page_live or previewable):
        return render(
            request,
            'applications/event_not_live.html',
            {'city': event.city, 'page_url': page_url, 'past': event.date <= now_approx}
marksweb commented 3 years ago

Could do with the sentry context on this one to really see what is going on with the data through the stacktrace on this.

marksweb commented 3 years ago

@amakarudze I requested sentry access to assist with this. Should be a simple fix once I can see what's happening with the live site.

marksweb commented 3 years ago

@amakarudze Looking at the Sentry error on this one, I think this is likely invalid data on the event in the database. It would appear that this particular event doesn't have a date.

If you could confirm, I'll make the view more defensive & just say that if the date is invalid in that scenario then the event is in the past.

amakarudze commented 3 years ago

@marksweb wow! Thanks for picking that up. Yes, I checked the database and the event doesn't have a date. I wondered why the error keeps appearing, it's a data issue.