Reputation: 39
def frontblog(request):
if request.method=='POST':
for post in Posts.objects(tags=request.POST('search')):
posttitle=post.post_title
postcont=post.post_content
postdate=post.post_date
posttag=post.post_tags
return render_to_response("frontblog.html",
RequestContext(request,
{'post':post}))
I have tried to send the data from mongo db database as by search using tag post get retrieved and should be send to display on html page.
Upvotes: 0
Views: 105
Reputation: 77942
NB : answer based on badly indented code, so it's a bit of a guessing game... but if you want a correct answer learn to post correctly indented code.
You start your code with a test on request.method=='POST'
and everything else is under that branch, which means that if it's a GET request (or PUT or whatever) your view function implicitely returns None
.
There are quite a few other WTFs in your code but fix this one first. BTW a "search" should be done as GET request, not POST. Also, in a POST request, request.GET
will most probably be empty. Finally, you DO want to use a Form
to sanitize user inputs... Well, unless you don't mind your site or app being hacked by the first script-kiddie, that is.
Upvotes: 1