def new_post(blog_id, username, password, post, publish): user = authenticate(username, password) item = News() item.title = post['title'] item.description = post['description'] if post.get('dateCreated'): item.dateCreated = datetime.strptime(str(post['dateCreated']),'%Y%m%dT%H:%M:%S') else: item.dateCreated = datetime.now().date() item.author = user item.publish = publish item.categories = Categories.objects.get(name=u'Новости сайта') item.save() return item.pk