Search code examples
pythondjangodjango-comments

Modifiying a Django view for a certain project


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.delete_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?


Solution

  • 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 :-) ).