This is my action in default.py (Everything is working fine, except the 
form in the view, if I write and submit the post, it gives this error above)
@auth.requires_login()
def timeline():
    db.post.posted_by.default =  auth.user_id
    db.post.posted_on.default = request.now
    #create form with which the user can submit posts
    crud.settings.formstyle = 'table2cols'
    form = crud.create(db.post)
    #determine who the user follows
    my_followees = db(db.followers.follower==me)
    me_and_my_followees = [me]+[row.followee for row in 
my_followees.select(db.followers.followee)]
    #Pull all posts to be displayed
    postings = 
db(db.post.posted_by.belongs(me_and_my_followees)).select(orderby=~db.post.posted_on,limitby=(0,100))
    return locals()


In db.py model

db.define_table('post',
                Field('body', 'text', requires=IS_LENGTH(280, 1), 
label="What's going down?" ),
                Field('posted_by', 'reference auth_user'),
                Field('posted_on', 'datetime', 
requires=IS_DATETIME('%d-%m-%Y    %H:%M:%S'))
                )
db.post.body.required = True
db.post.body.requires = IS_LENGTH(280, 1)

db.post.posted_on.required = True
db.post.posted_by.required = True
db.post.posted_on.default = request.now

db.post.posted_on.writable = db.post.posted_on.readable = False
db.post.posted_by.writable = db.post.posted_by.readable = False

My view below
{{extend 'layout.html'}}
 <a class="btn polsearch"   href="{{=URL(c="default", f="search")}}" ><i 
class="icon-search icon-white spaceit"></i>Search for politicians, people 
to follow...</a>
{{=A(T("Start a petition"), _href=URL('admin','default','index'), 
_class='btn petition pull-right',
     _style='margin-top: 1em;')}}
<hr>
{{=form}}
<script>$('textarea').css('width','600px').css('height', '50px');</script>
{{for post in postings:}}
<div style="background:#F0FFFF; margin-bottom:5px; padding:8px; 
width:600px;">
    <h4>{{=name_of(post.posted_by)}} on {{=post.posted_on}}</h4>
    {{=MARKMIN(post.body)}}
    </div>
{{pass}}

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to