DjangoBB

Django based forum engine

  • You are not logged in.

#1 Sept. 23, 2011 14:24:06

scrapper
Registered: 2010-12-20
Posts: 43
Reputation: +  0  -
Profile   Send e-mail  

write post to database

Hello,

this is not a bug. But please help me on that one. I did not post the question to a django or python forum, because I want to make a djangobb post to my database(postgresql).

When i try to write a little new post to the postgresql database I get the following error message:
…ValidationError: [u'Enter a valid date/time in YYYY-MM-DD HH:MM[:ss] format.']

from djangobb_forum.models import Post
...
p = Post(id='5', topic_id='1', user_id='1', created=datetime.now(), updated='', updated_by_id='', markup='bbcode', body='text', body_html='<b>text</b>', user_ip='127.0.0.1')
p.save()

So the problem is at created.
I have tried a million of things, also created='2011-23-09 16:55:03.123456' etc… really a lot of things.
I have searched the entire web, but no luck. I am messing around with this too many hours now.
I am able to save strings to the database no problem. but with the “timestamp with time zone” I have no idea how to do it.
I know the database and everything works, when i post a post via the webform it works just fine. But not with my simple code.

Thanks a lot for your help in advance!
sc

Edited scrapper (Sept. 23, 2011 14:24:43)

Offline

#2 Sept. 23, 2011 17:55:19

scrapper
Registered: 2010-12-20
Posts: 43
Reputation: +  0  -
Profile   Send e-mail  

write post to database

ok:
I will tell you guys what works so far.

If i do a:
posts = Posts.objects.all()
post = posts[0]
post.created=datetime.now()
post.body='new body text'
post.save()

this works totally fine.
So my question is, why does it not work with the self generated content from above?

Any hints greatly appreciated!
Thanks in advance!
sc

Offline

#3 Sept. 23, 2011 18:35:27

scrapper
Registered: 2010-12-20
Posts: 43
Reputation: +  0  -
Profile   Send e-mail  

write post to database

guys forget everything I told you.
As so often the problem was somewhere else.

The problem was not at created… it was at updated. As you can easily see I had updated='' as a String. But it actually should be of type datetime.

Must have been too tired to see the solution in front of my eyes.
Solved

Edited scrapper (Sept. 23, 2011 19:02:40)

Offline

Board footer

Moderator control

Powered by DjangoBB

Lo-Fi Version