示例#1
0
def create(request, name):

    #    user = User.create_user(username='******', email='*****@*****.**', password='******')
    #    user.is_staff = True
    #    user.save()
    post1 = TextPost(title="Fun with MongoEngine", author=name)
    post1.save()
    return HttpResponse("Created")
示例#2
0
def populate_data():
    john = User(email='*****@*****.**', first_name="John", last_name="Doe")
    john.save()

    post1 = TextPost(title="Fun with MongoEngine", author=john)
    post1.content = "Took a look at MongoEngine today, looks pretty cool."
    post1.tags = ['mongodb', 'mongoengine']
    post1.save()

    post2 = LinkPost(title="MongoEngine Documentation", author=john)
    post2.link_url = "http://tractiondigital.com/labs/mongoengine/docs"
    post2.tags = ["mongoengine"]
    post2.save()
示例#3
0
def save_message_post(request):
    """
    Saves a MessagePost
    """
    form = TextForm(request.POST)

    if form.is_valid():
        newdoc = TextPost(body = request.POST["body"])
        newdoc.save()   
        return_obj = TextPost.objects.all().order_by('-created')[:1]
    else:
        print form.errors
 
    return return_obj 
示例#4
0
def create_post_by_user():
    john = User(email='*****@*****.**')
    john.first_name = 'john'
    john.last_name = 'Lawley'
    john.save()

    post1 = TextPost(title='Fun with MongoEngine', author=john)
    post1.content = 'Took a look at MongoEngine today, looks pretty cool.'
    post1.tags = ['mongodb', 'mongoengine']
    post1.save()

    post2 = LinkPost(title='MongoEngine Documentation', author=john)
    post2.link_url = 'http://docs.mongoengine.com/'
    post2.tags = ['mongoengine']
    post2.save()