Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 8, 2005 01:44:43

Brett H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


(latest svn checkout)

I can't seem to get a meta.TimeField to work properly (using the admin
panel for now). DateField works fine, and DateTimeField works only if
I let auto_now_add do the work (in other words, if auto_now_add is True
and I don't set the Date/Time manually)

Anyways, for now... TimeField.

******
MODEL:
******

class Post(meta.Model):
date = meta.DateField(auto_now_add=True)
time = meta.TimeField(auto_now_add=True)
modified = meta.DateTimeField(auto_now=True)
title = meta.CharField(maxlength=50)
post_slug = meta.SlugField(blank=True)
content = meta.TextField()
category = meta.ForeignKey(Category, blank=True, null=True)
status = meta.CharField(maxlength=2, choices=STATUS_CHOICES,
radio_admin=True, default='DR')
comment_status = meta.CharField(maxlength=2,
choices=COMMENT_STATUS_CHOICES, radio_admin=True, default='OP')

class META:
unique_together = (("date", "post_slug"),)
module_constants={'slugify': slugify}
admin = meta.Admin(
fields = (
('General', {'fields': ('title', 'category',
'content',)}),
('Status Settings', {'fields': ('status',
'comment_status',)}),
('Date and Time', {'fields': ('date', 'time',)}),
),
)

******
ERROR:
******

KeyError at /admin/blog/posts/add/
"Could not find Formfield or InlineObjectCollection named 'time'"
Request Method: GET
Request URL:http://localhost:8000/admin/blog/posts/add/Exception Type: KeyError
Exception Value: "Could not find Formfield or InlineObjectCollection
named 'time'"
Exception Location:
C:\Python24\lib\site-packages\django\core\formfields.py in
__getitem__, line 119

I can post more as needed, but this is all I really have to work on now
and I'm pretty confused.

(egenix-mxDateTime 2.0.6, if that matters)

Offline

#2 Dec. 8, 2005 02:51:09

Brett H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


By the way, someone noted that I was using "time" and "date" - both
reserved words. Woops. Well, I changed them to "time_posted",
"date_posted", etc, and I still get the same error.

KeyError at /admin/blog/posts/add/
"Could not find Formfield or InlineObjectCollection named 'time_posted'"

Offline

#3 Dec. 8, 2005 03:18:52

Brett H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


luminosity in IRC asked if I tried it without "auto_now_add=True" ... I
tried, and it worked.

So what am I doing wrong with "auto_now_add" here?

Offline

#4 Dec. 8, 2005 04:31:22

Brett H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


Ah, well... I've realized by messing around that "auto_now_add" assumes
you aren't even going to display it. I was assuming that it would
auto_add if you left it blank ... woops yet again. I think that would
be nice though, or at least clear that up in the Docs, unless I missed
something. :P

Offline

#5 Dec. 8, 2005 05:16:21

Daniel E.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


On 8 dec 2005, at 04.18, Brett Hoerner wrote:luminosity in IRC asked if I tried it without"auto_now_add=True" ... Itried, and it worked.

So what am I doing wrong with "auto_now_add" here?I'm not sure you are doing anything wrong. When you set auto_now orauto_now_add on the TimeField it isn't editable. Inserting it intothe Admin with the META-fields property should maybe revert this andit does for DateField and DateTimeField but not for TimeField. I'veonly had a look at the meta code and if you comment out 629 in django/core/meta/fields.py and insert kwargs = True as forDateFields you will see your TimeField.django/core/meta/fields.py
624 class TimeField(Field):
625 empty_strings_allowed = False626 def __init__(self, verbose_name=None, name=None,auto_now=False, auto_now_add=False, **kwargs):627 self.auto_now, self.auto_now_add = auto_now, auto_now_add
628 if auto_now or auto_now_add:
629 #kwargs = False
630 kwargs = True
631 Field.__init__(self, verbose_name, name, **kwargs)

- Daniel

Offline

#6 Dec. 8, 2005 05:31:29

Brett H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


Thanks, so... should this be changed in the Django-svn, or is this some
special functionality I should really need/depend on?

Also, I still think that users should be able to over-ride the values
with auto_add on ... if they post data that should 'take', if the
field is blank it should do the normal stuff, if that makes sense.
Just a vote though, maybe I'm not seeing a reason for the way it is?

Thanks much though, Daniel.

Offline

#7 Dec. 8, 2005 05:33:13

Daniel E.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


On 8 dec 2005, at 06.16, Daniel Ericsson wrote:On 8 dec 2005, at 04.18, Brett Hoerner wrote:luminosity in IRC asked if I tried it without"auto_now_add=True" ... Itried, and it worked.

So what am I doing wrong with "auto_now_add" here?I'm not sure you are doing anything wrong. When you set auto_now orauto_now_add on the TimeField it isn't editable. Inserting it intothe Admin with the META-fields property should maybe revert thisand it does for DateField and DateTimeField but not for TimeField.I've only had a look at the meta code and if you comment out 629 indjango/core/meta/fields.py and insert kwargs = True as forDateFields you will see your TimeField.django/core/meta/fields.py
624 class TimeField(Field):
625 empty_strings_allowed = False626 def __init__(self, verbose_name=None, name=None,auto_now=False, auto_now_add=False, **kwargs):627 self.auto_now, self.auto_now_add = auto_now,auto_now_add628 if auto_now or auto_now_add:
629 #kwargs = False
630 kwargs = True
631 Field.__init__(self, verbose_name, name, **kwargs)There seem to be a fix in the new-admin branch -> http://code.djangoproject.com/changeset/1244- Daniel

Offline

#8 Dec. 8, 2005 05:41:18

Tom T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


On 12/8/05, Daniel Ericsson <> wrote:
> There seem to be a fix in the new-admin branch -> http://
> code.djangoproject.com/changeset/1244

Or, in other words, the current trunk, since new-admin got merged a
little while back. :-)

In general, if you're having a problem and you're using 0.90, try out
trunk to see if your problem has already been solved -- just like
magic! :-D

Offline

#9 Dec. 8, 2005 05:47:34

Brett H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


Well, I'm using the latest svn checkout, at least as of last night, as
I noted in my first problem post. So, the error with TimeField and
auto_add* is still there for me.

Offline

#10 Dec. 8, 2005 06:07:39

Tom T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

TimeField Problem/Question


On 12/8/05, Brett Hoerner <> wrote:
>
> Well, I'm using the latest svn checkout, at least as of last night, as
> I noted in my first problem post. So, the error with TimeField and
> auto_add* is still there for me.

I guess I got thrown off by Daniel's suggestion; sorry to hear that
the problem's still there for you. :-(

Offline

Board footer

Moderator control

Enjoy the 23rd of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support