0

While updating the edited blog i am getting this error: in edit_article function Here is my function,

def edit_article(request, id):
    session_start(request)
    if Article.exists(id):
        article = Article.getByName(id)
    else:
        article = Article(id)
    if request.method == 'POST' and request.POST in "content":
        if has_article_access(request, article):
            article.body = request.POST['content']
            article.save()
            if 'counter_edit' in request.session:
                request.session['counter_edit'] += 1
            else:
                request.session['counter_edit'] = 1
            delete_article_locked(request, article)
            return HttpResponseRedirect('/myblog/?edited')
        else:
            return HttpResponseRedirect('/myblog/?locked')
    else:
        if has_article_access(request, article):
            start_article_locked(request, article)
        else:
            return HttpResponseRedirect('/myblog/?locked')
        return render_to_response("edit.html",
                                  {
                                   'name': article.title,
                                   'content': article.body,
                                   'id':article.id
                                  },
                                  context_instance=RequestContext(request)
        )

The error shows in 7th line.

2
  • 1
    request.POST in "content". You're trying to check if the POST dictionary is in the string "content". Commented Oct 12, 2016 at 13:16
  • Do you mean "content" in request.POST? Commented Oct 12, 2016 at 13:22

1 Answer 1

1

If you want to check if request.POST has the key "content":

if request.method == 'POST' and "content" in request.POST:
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score. This is what it said when i tried to vote. And this is the reason.
It's not a vote, you have to accept the answer if it solved your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.