Opened 14 years ago

Last modified 14 years ago

#13872 closed

"AttributeError: 'module' object has no attribute 'day_abbr'" when using Admin to add instance of model with DateField, TimeField, or DateTimeField — at Version 1

Reported by: Lexo Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords: attributeerror module day_abbr strptime datefield datetime datetimefield timefield admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

I'm running Django 1.2.1 on Python 2.5.4

Whenever I try to add a new instance of a model that contains one of either DateTimeField, DateField, or TimeField, I get "AttributeError: 'module' object has no attribute 'day_abbr'"

I have a feeling it's related to http://code.djangoproject.com/ticket/13560 but I'm not sure.

Here are my models. Adding a Baz works just fine, but adding a Bar causes the exception:

from django.db import models

class Bar(models.Model):
    name = models.TextField()
    publish_date = models.DateTimeField()


class Baz(models.Model):
    name = models.CharField(max_length = 10)
    age = models.IntegerField()

And a traceback:

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/foo/bar/add/
Django Version: 1.2.1
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.admin',
 'foobar.foo']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in wrapper
  239.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapped_view
  76.                     response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
  69.         response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in inner
  190.             return view(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapper
  21.             return decorator(bound_func)(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapped_view
  76.                     response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in bound_func
  17.                 return func(self, *args2, **kwargs2)
File "C:\Python25\Lib\site-packages\django\db\transaction.py" in _commit_on_success
  299.                     res = func(*args, **kw)
File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in add_view
  777.             if form.is_valid():
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in is_valid
  121.         return self.is_bound and not bool(self.errors)
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in _get_errors
  112.             self.full_clean()
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in full_clean
  267.         self._clean_fields()
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in _clean_fields
  284.                     value = field.clean(value)
File "C:\Python25\Lib\site-packages\django\forms\fields.py" in clean
  775.                 clean_data.append(field.clean(field_value))
File "C:\Python25\Lib\site-packages\django\forms\fields.py" in clean
  162.         value = self.to_python(value)
File "C:\Python25\Lib\site-packages\django\forms\fields.py" in to_python
  342.                 return datetime.date(*time.strptime(value, format)[:3])
File "C:\Python25\lib\_strptime.py" in <module>
  272. _TimeRE_cache = TimeRE()
File "C:\Python25\lib\_strptime.py" in __init__
  191.             self.locale_time = LocaleTime()
File "C:\Python25\lib\_strptime.py" in __init__
  74.         self.__calc_weekday()
File "C:\Python25\lib\_strptime.py" in __calc_weekday
  94.         a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]

Exception Type: AttributeError at /admin/foo/bar/add/
Exception Value: 'module' object has no attribute 'day_abbr'

Change History (1)

comment:1 by Ramiro Morales, 14 years ago

Description: modified (diff)

Reformatted, please use correct WikiFormatting and the Preview button before sumbitting the ticket.

Note: See TracTickets for help on using tickets.
Back to Top