I am having a big problem. I have the following tables
db.define_table('post',
Field('user_email', default=auth.user.email if auth.user_id else None),
Field('title', 'string', requires=IS_NOT_EMPTY()),
Field('body', 'text', requires=IS_NOT_EMPTY()),
Field('votes', 'integer', default=0, readable=False, writable=False),
auth.signature
)
db.define_table('comm',
Field('post','reference post'),
Field('body','text'),
auth.signature
)
So basically the user is able to create a post when he is logged in. I want to add the feature of adding comments on a post without reloading the whole page. In this case I would think I have to use the ajax function.
I don't quiet understand the way 'reference' works. I think that when I insert a new text I have to specify which post is coming from, but as I said, I am confused. Can u provide a brief explanation of how to relate the two tables? because I have to code a python function in which I have to specify the comments to be displayed on a specific post.
<div class="well">
<h1>{{=post.title}}</h1>
{{=post.body}}
</div>
{{if field_var_created_by == auth.user_id:}}
<a href={{=URL('edit_post',args=post.id)}} class="btn btn-danger" role="button">Edit Post</a>
{{pass}}
<form>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="5" id="comment"></textarea>
<script>
document.write('hello');
</script>
</div>
</form>
<a href="" class="btn btn-success" role="button">Add Comments</a>
As you can see I retrieved all the data of a post on a view by using a python function in the controller. I want to get the input of text area, put it in the database and then somehow display it on this post.
https://wwu39.pythonanywhere.com/prostudy
I have my website booted up on pythonanywhere. The problem I am having is in the forum page. To access the forum you have to log in. Don't worry I am not going to spam you. This is a small app no one will use. Go to forum, select a post and you will see the problem. The add comment button doesn't do anything yet. I have disabled the user authentication feature to make things easier for you