#13872 closed (worksforme)
"AttributeError: 'module' object has no attribute 'day_abbr'" when using Admin to add instance of model with DateField, TimeField, or DateTimeField
| 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 )
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 (5)
comment:1 by , 15 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 15 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
Tested on a clean project with versions you gave. I'm guessing you named one of your apps or some other module "calendar" which breaks the built-in python module. Rename your app/module and it should work fine. A similar problem on django-users from the past.
comment:3 by , 15 years ago
Thanks for looking into this. I thought it might have been something like that too, which is why I started a new project named Foobar, with app Foo, and models Bar and Baz. I'm just going to try a fresh install of Python and Django.
comment:4 by , 15 years ago
Yup - a fresh install of Python (not just Django) solved this. Thanks again for your help.
comment:5 by , 15 years ago
I found the original source of the problem - I had Google's gdata API installed, which includes a "calendar".
Reformatted, please use correct WikiFormatting and the Preview button before sumbitting the ticket.