django: Remove ugly "Thank you for your comment" message after posting comments

Django comments are really really easy to use, but one of the strangest quirks is that it displays a really ugly confirmation page after you've posted a comment. Luckily, its easy to fix.

image The first option is to prevent it from being shown altogether.

{% with your_object.get_absolute_url as next %}
{% render_comment_form for your_object %}
{% endwith %}

The second is to override the "content" block with a custom "comments/posted.html" file. That way you can fill it up with all sorts of silly messages.

  • Create "your_project/templates/comments/posted.html"
  • In it, put:

{% extends "your_base_file.html" %}

{% block content %}This is another silly message.{% endblock content %}

This way, you can still get your site's look and feel when displaying the thank you message.

Python: Define a static function in a class

Most functions in a class will refer to a "self" instance.

If you want a static function, you'll have to add the @staticmethod decorator.

class Something(object):
@staticmethod
def get_by_name(name):
return "Hello world"

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog