Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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: UI/UX:

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 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:


Request Method: POST
Request URL: http://localhost:8000/admin/foo/bar/add/
Django Version: 1.2.1
Python Version: 2.5.4
Installed Applications:
Installed Middleware:

File "C:\Python25\Lib\site-packages\django\core\handlers\" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\" in wrapper
  239.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\" in _wrapped_view
  76.                     response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\views\decorators\" in _wrapped_view_func
  69.         response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\" in inner
  190.             return view(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\" in _wrapper
  21.             return decorator(bound_func)(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\" in _wrapped_view
  76.                     response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\" in bound_func
  17.                 return func(self, *args2, **kwargs2)
File "C:\Python25\Lib\site-packages\django\db\" in _commit_on_success
  299.                     res = func(*args, **kw)
File "C:\Python25\Lib\site-packages\django\contrib\admin\" in add_view
  777.             if form.is_valid():
File "C:\Python25\Lib\site-packages\django\forms\" in is_valid
  121.         return self.is_bound and not bool(self.errors)
File "C:\Python25\Lib\site-packages\django\forms\" in _get_errors
  112.             self.full_clean()
File "C:\Python25\Lib\site-packages\django\forms\" in full_clean
  267.         self._clean_fields()
File "C:\Python25\Lib\site-packages\django\forms\" in _clean_fields
  284.                     value = field.clean(value)
File "C:\Python25\Lib\site-packages\django\forms\" in clean
  775.                 clean_data.append(field.clean(field_value))
File "C:\Python25\Lib\site-packages\django\forms\" in clean
  162.         value = self.to_python(value)
File "C:\Python25\Lib\site-packages\django\forms\" in to_python
  342.                 return*time.strptime(value, format)[:3])
File "C:\Python25\lib\" in <module>
  272. _TimeRE_cache = TimeRE()
File "C:\Python25\lib\" in __init__
  191.             self.locale_time = LocaleTime()
File "C:\Python25\lib\" in __init__
  74.         self.__calc_weekday()
File "C:\Python25\lib\" 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 Changed 7 years ago by Ramiro Morales

Description: modified (diff)

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

comment:2 Changed 7 years ago by Łukasz Rekucki

Resolution: worksforme
Status: newclosed

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 Changed 7 years ago by Lexo

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 Changed 7 years ago by Lexo

Yup - a fresh install of Python (not just Django) solved this. Thanks again for your help.

comment:5 Changed 7 years ago by Lexo

I found the original source of the problem - I had Google's gdata API installed, which includes a "calendar".

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