Login

Snippets by rpoulton

Snippet List

Redirect Multiple Domains to a Single Domain

Often, you may register more than one domain name for your website, which may have a primary domain of *mysite.com.au*: 1. mysite.com 2. my-site.com 3. mysite.net 4. mysite.co.uk For SEO and brand awareness reasons, (remember: every page should have exactly one URL) you want every visitor to end up on your primary domain, *mysite.com.au*. This middleware checks the HTTP_HOST for all incoming requests, and sends the user to http://www.mysite.com.au/ if they've managed to hit another domain.

  • middleware
  • redirect
  • domains
Read More

Using Templates to Send E-Mails

This is a basic example for sending an email to a user (in this case, when they've signed up at a website) using the Django template framework. It's really quite simple - we're just using a plain text template instead of HTML, and using the output of the template's 'render()' method as the message body. Of course, in your project you won't blindly use data from request.POST! This example was first posted on [my blog at rossp.org](http://www.rossp.org/blog/2006/jul/11/sending-e-mails-templates/)

  • templates
  • email
Read More

rpoulton has posted 2 snippets.