开发者

Modifiying a Django view for a certain project

开发者 https://www.devze.com 2022-12-20 16:55 出处:网络
So I simply want to use the delete() from the django.contrib.comments.views.moderation module, but only allowing the users with permission to delete their comments. In order to do this, all I have to

So I simply want to use the delete() from the django.contrib.comments.views.moderation module, but only allowing the users with permission to delete their comments. In order to do this, all I have to do is uncomment #@permission_required("comments.d开发者_运维问答elete_comment"), but I want to be able to do this without modifying the django framework. How can I modify/extend this view to my project? I guess the better question would be, what is the best way to change the setting for the delete() without changing anything in the django framework?


That line is only commented out because Django 1.1 maintains compatibility with Python 2.3 which doesn't support the decorator (@) syntax. But the view is decorated with permission_required nonetheless (with syntax that is compatible with Python 2.3), as you can see here. Django 1.2 will drop support for Python 2.3 and will switch to the @-syntax. This is already visible on trunk.

Bottom line: you have to do nothing, as Django does already exactly what you want (this seems to be a recurring theme with Django :-) ).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号