'module' object has no attribute 'day_abbr' --Problem editing using Admin

1108 views
Skip to first unread message

Ryan Vanasse

unread,
Mar 31, 2008, 12:58:37 AM3/31/08
to Django users
I'm sorry for writing at such an early, clueless time in my learning
process (both with python and django) but this problem appears to be
in code I didn't write and I'm not sure what the best way to work
around this problem is. I'm sorry for not having lurked more to
understand the norms of this group, but I need to jump right into
learning this.

If there is a better way for me to look for help for something like
this, please let me know.


When saving an event model in the built-in Django Admin, I get this
error:

AttributeError at /admin/calendar/event/add/
'module' object has no attribute 'day_abbr'
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/calendar/event/add/
Exception Type: AttributeError
Exception Value: 'module' object has no attribute 'day_abbr'
Exception Location: C:\Python25\lib\_strptime.py in __calc_weekday,
line 94

My model code is as follows:

from django.db import models

class Event(models.Model):
eventName = models.CharField(maxlength=63)
#eventDate = models.DateField()
start_time = models.DateTimeField()
end_time = models.DateTimeField()
eventLocation = models.CharField(maxlength = 63)
eventDetails = models.TextField()

def __str__(self):
return self.eventName

class Admin:
list_display = ('eventName', 'eventLocation',)
list_filter = ('eventLocation',)
ordering = ('-eventDate',)
search_fields =('eventName','eventLocation',)

I don't know if the traceback is helpful here, but I figured it was
easier to include now rather than later. (If this is not the cultural
norm here, please let me know.)

Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\lib\site-packages\django\contrib\admin\views
\decorators.py" in _checklogin
55. return view_func(request, *args, **kwargs)
File "C:\Python25\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
39. response = view_func(request, *args, **kwargs)
File "C:\Python25\lib\site-packages\django\contrib\admin\views
\main.py" in add_stage
251. manipulator.do_html2python(new_data)
File "C:\Python25\lib\site-packages\django\oldforms\__init__.py" in
do_html2python
103. field.convert_post_data(new_data)
File "C:\Python25\lib\site-packages\django\oldforms\__init__.py" in
convert_post_data
335. converted_data = [self.__class__.html2python(data) for data in
d]
File "C:\Python25\lib\site-packages\django\oldforms\__init__.py" in
html2python
822. time_tuple = time.strptime(data, '%Y-%m-%d')
File "C:\Python25\lib\_strptime.py" in
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)]

AttributeError at /admin/calendar/event/add/
'module' object has no attribute 'day_abbr'

Thank you for your assistance?

Kenneth Gonsalves

unread,
Mar 31, 2008, 1:26:58 AM3/31/08
to django...@googlegroups.com

On 31-Mar-08, at 10:28 AM, Ryan Vanasse wrote:

> class Event(models.Model):
> eventName = models.CharField(maxlength=63)
> #eventDate = models.DateField()
> start_time = models.DateTimeField()
> end_time = models.DateTimeField()
> eventLocation = models.CharField(maxlength = 63)
> eventDetails = models.TextField()
>
> def __str__(self):
> return self.eventName
>
> class Admin:
> list_display = ('eventName', 'eventLocation',)
> list_filter = ('eventLocation',)
> ordering = ('-eventDate',)
> search_fields =('eventName','eventLocation',)

you have eventDate commented out in the model, but are specifying
ordering by eventDate. I am sure the model is getting saved, and this
error arises on generating the change list after the save.

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/

Ryan Vanasse

unread,
Mar 31, 2008, 2:25:57 AM3/31/08
to Django users
I just commented out the ordering, and it's bringing up the same
error.

When I try looking at the Events list (to check if anything was
added), and got a Template syntax error. (see below)
I used an SQLite admin program to check out what was in the
calendar_Events table and found nothing.

I have a couple of other projects on the same install (for
experimentation) and they all appear to be working.
I'm using .96

Template syntax error:
TemplateSyntaxError at /admin/calendar/event/
'admin_list' is not a valid tag library: Could not load template
library from django.templatetags.admin_list, cannot import name isleap
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/calendar/event/
Exception Type: TemplateSyntaxError
Exception Value: 'admin_list' is not a valid tag library: Could not
load template library from django.templatetags.admin_list, cannot
import name isleap
Exception Location: C:\Python25\lib\site-packages\django\template
\defaulttags.py in load, line 750

Erik Vorhes

unread,
Apr 1, 2008, 10:09:01 AM4/1/08
to django...@googlegroups.com
That's because the table storing your information doesn't have an
"EventDate" field, and it can't be ordered by something that doesn't
exist. You'll need to update the table before it will work correctly.

Ryan Vanasse

unread,
Apr 2, 2008, 1:18:01 AM4/2/08
to Django users
Thanks for the reply. I checked the DB file and yes, you were correct
about the updating the table.

I updated it using the manage.py sqlreset command. Currently it
contains an event date of type "date" (in the database mind you).

However, I also commented out, and then removed for good measure, the
"ordering" part of the model. Still nothing.

The exception is relating to _strptime.py.

I am wondering if maybe there's some conflict because my app name is
calendar...is it possible that this conflicts with a calendar object
in _strptime.py?

On Apr 1, 9:09 am, "Erik Vorhes" <e...@textivism.com> wrote:
> That's because the table storing your information doesn't have an
> "EventDate" field, and it can't be ordered by something that doesn't
> exist. You'll need to update the table before it will work correctly.
>

Erik Vorhes

unread,
Apr 2, 2008, 11:09:42 AM4/2/08
to django...@googlegroups.com
I'm not much good with Python directly, but it might have something to
do with an import statement at the top of your models.py -- or you
might have a typo somewhere. Is there a time when you're trying to
convert a date/time to a string with strftime? (Note the "f" instead
of the "p".)

Karen Tracey

unread,
Apr 2, 2008, 2:08:12 PM4/2/08
to django...@googlegroups.com
On Wed, Apr 2, 2008 at 1:18 AM, Ryan Vanasse <onetrue...@gmail.com> wrote:

Thanks for the reply. I checked the DB file and yes, you were correct
about the updating the table.

I updated it using the manage.py sqlreset command. Currently it
contains an event date of type "date" (in the database mind you).

However, I also commented out, and then removed for good measure, the
"ordering" part of the model. Still nothing.

The exception is relating to _strptime.py.

I am wondering if maybe there's some conflict because my app name is
calendar...is it possible that this conflicts with a calendar object
in _strptime.py?


It conflicts with Python's built in calendar:

http://docs.python.org/lib/module-calendar.html

_strptime.py does 'import calendar' thinking it will get Python's calendar but instead it gets your project calendar, which doesn't work for it.
 
You need to call your app something that isn't already in use.  When in doubt, open up a Python prompt and try 'import xyzzy'.  If it doesn't respond 'ImportError: No module named xyzzy' (where xyzzy is your chosen name, of course), then it's not a name you should use for an app.

Karen

Ryan Vanasse

unread,
Apr 3, 2008, 1:04:40 AM4/3/08
to Django users
After looking at the exception some more, I was thinking it would be
that.

Well, I'll have to rename the app...since I'm pretty early in the dev
process I should be alright. Thanks kenneth, Erik, and Karen, for your
help.

And especially thanks for the import test statement. It's one of those
"duh" things but it's really useful to me when I'm just starting out.

Again, thanks!
ryan


On Apr 2, 1:08 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:
> On Wed, Apr 2, 2008 at 1:18 AM, Ryan Vanasse <onetruesprin...@gmail.com>
Reply all
Reply to author
Forward
0 new messages