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 Initial Version
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
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
- response = callback(request, *callback_args, callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in wrapper
- return self.admin_site.admin_view(view)(*args, kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapped_view
- response = view_func(request, *args, kwargs)
File "C:\Python25\Lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
- response = view_func(request, *args, kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in inner
- return view(request, *args, kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapper
- return decorator(bound_func)(*args, kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapped_view
- response = view_func(request, *args, kwargs)
File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in bound_func
- return func(self, *args2, kwargs2)
File "C:\Python25\Lib\site-packages\django\db\transaction.py" in _commit_on_success
- res = func(*args, kw)
File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in add_view
- if form.is_valid():
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in is_valid
- return self.is_bound and not bool(self.errors)
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in _get_errors
- self.full_clean()
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in full_clean
- self._clean_fields()
File "C:\Python25\Lib\site-packages\django\forms\forms.py" in _clean_fields
- value = field.clean(value)
File "C:\Python25\Lib\site-packages\django\forms\fields.py" in clean
- clean_data.append(field.clean(field_value))
File "C:\Python25\Lib\site-packages\django\forms\fields.py" in clean
- value = self.to_python(value)
File "C:\Python25\Lib\site-packages\django\forms\fields.py" in to_python
- return datetime.date(*time.strptime(value, format)[:3])
File "C:\Python25\lib\_strptime.py" in <module>
- _TimeRE_cache = TimeRE()
File "C:\Python25\lib\_strptime.py" in init
- self.locale_time = LocaleTime()
File "C:\Python25\lib\_strptime.py" in init
- self.calc_weekday()
File "C:\Python25\lib\_strptime.py" in calc_weekday
- 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'}}}