Search - User list
Full Version: write post to database
Root » Bugs » write post to database
1
scrapper
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

scrapper
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
scrapper
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
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB