Add a "featured" feature to the Pythonic Forum (cont.)

Source: Internet
Author: User

In the previous blog, "Add a feature" to the Pythonic forum, which limits posting on the template level. That is, depending on whether the user has permissions to decide whether to display the posting box.

But since so "opportunistic" after writing the template, tossing and turning all night, do not know whether the user can not be able to post the node in the local Add post box to implement the post.

In the end, I still think it is not reliable ... It needs to be verified on the server side as well. Simple handling, and finally filled the pit

Look through the \apps\topic\views.py file to find Def topic_create (Request, Node_slug): function definition.

if  node.category.name = = u" parent node name ":    ifnot  Request.user.is_staff:        raise Http404

This determines whether the user posts to the specified node and determines whether to continue saving based on user rights

There are some problems in the process. The first to write Request.user.is_staff Request.user.is_staff () causes an error "' bool ' object is not callable"

There is a comparison when the "parent node name" does not precede the U, resulting in a comparison is unsuccessful. Later thought was the problem of coding.

"The paper came to the end to know that the matter to be preach"-read the time is seen, but write their own will forget the details.

OK, just like this, after all, the pit filled

Add a "featured" feature to the Pythonic Forum (cont.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.