Login

Snippets by mathijs

Snippet List

comments_allowed function for your model/...

Use this if you want to check if commenting is allowed for a certain object/model/... in a template. Like this; `{% if not object.comments_allowed %} <p>Comments are now closed.</p> {% else %} {% render_comment_form for object %} {% endif %}` You can replace the CommentModerator class with your own custom moderation class ofcourse.

  • comments
  • moderation
Read More

Changing the locale temporary

This piece of code allows the quickly set the locale to a different language. This can be used for instance in cron jobs to send emails to users in their specific language. This is pretty rough code, it be better to create an object, having two functions: set_locale and reset_locale. set_locale would than contain steps 1 to 4 (and return the request object on succes), reset_locale would be step 6 Enjoy!

  • django
  • locale
Read More

mathijs has posted 2 snippets.