AttributeError: 'str' object has no attribute 'year' · Issue ...
github.com › DjangoGirls › djangogirlsAttributeError: '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 ...
python - DateField 'str' object has no attribute 'year ...
stackoverflow.com › questions › 34131468Dec 07, 2015 · When trying to access the year and month attributes of my DateField objects I am getting the error. AttributeError: 'str' object has no attribute 'date'. I thought that DateField objects were saved as Python Datetime objects instead of strings. class MonthControlRecord (models.Model): STATUS_CHOICES = ( (0, 'Open'), (1, 'Locked'), (2, 'Closed'), ) employee = models.ForeignKey (Employee, on_delete=models.CASCADE) first_day_of_month = models.DateField () status = models.IntegerField ...