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

  1. response = callback(request, *callback_args, callback_kwargs)

File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in wrapper

  1. return self.admin_site.admin_view(view)(*args, kwargs)

File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapped_view

  1. response = view_func(request, *args, kwargs)

File "C:\Python25\Lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func

  1. response = view_func(request, *args, kwargs)

File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in inner

  1. return view(request, *args, kwargs)

File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapper

  1. return decorator(bound_func)(*args, kwargs)

File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in _wrapped_view

  1. response = view_func(request, *args, kwargs)

File "C:\Python25\Lib\site-packages\django\utils\decorators.py" in bound_func

  1. return func(self, *args2, kwargs2)

File "C:\Python25\Lib\site-packages\django\db\transaction.py" in _commit_on_success

  1. res = func(*args, kw)

File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in add_view

  1. if form.is_valid():

File "C:\Python25\Lib\site-packages\django\forms\forms.py" in is_valid

  1. return self.is_bound and not bool(self.errors)

File "C:\Python25\Lib\site-packages\django\forms\forms.py" in _get_errors

  1. self.full_clean()

File "C:\Python25\Lib\site-packages\django\forms\forms.py" in full_clean

  1. self._clean_fields()

File "C:\Python25\Lib\site-packages\django\forms\forms.py" in _clean_fields

  1. value = field.clean(value)

File "C:\Python25\Lib\site-packages\django\forms\fields.py" in clean

  1. clean_data.append(field.clean(field_value))

File "C:\Python25\Lib\site-packages\django\forms\fields.py" in clean

  1. value = self.to_python(value)

File "C:\Python25\Lib\site-packages\django\forms\fields.py" in to_python

  1. return datetime.date(*time.strptime(value, format)[:3])

File "C:\Python25\lib\_strptime.py" in <module>

  1. _TimeRE_cache = TimeRE()

File "C:\Python25\lib\_strptime.py" in init

  1. self.locale_time = LocaleTime()

File "C:\Python25\lib\_strptime.py" in init

  1. self.calc_weekday()

File "C:\Python25\lib\_strptime.py" in calc_weekday

  1. 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 (0)

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