title: Migrate passwords from Drupal 7 to Django
body: <p>I am migrating a site from Drupal 7 to Django 1.4, including the current users. How can I work with the passwords that were hashed by Drupal?</p>
  
  <p>According to <a href="http://joncave.co.uk/2011/01/password-storage-in-drupal-and-wordpress/" rel="noreferrer">this</a>, Drupal 7 hashes passwords using SHA-512 (they are stored in the form of a string starting with "$S$").</p>
  
  <p>Django 1.4 now contains a number of <a href="https://docs.djangoproject.com/en/dev/topics/auth/" rel="noreferrer">options</a> for storing passwords, with a default of SHA-256, but I can't find an option for SHA-512. While <a href="https://github.com/fwenzel/django-sha2" rel="noreferrer">this app</a> appears to allow the use of SHA2 algorithms, I'm not sure it's compatible with Django 1.4 (as 1.4 has a flexible password hasher).</p>
  
  <p>What is the simplest way to do this?</p>
  
  <p>ETA: I've built a password hasher that mimics Drupal's algorithm and makes migration easy. Since I've already accepted an answer, I won't unaccept, but for anyone who wants to do Drupal to Django migration in the future, the code is stored on <a href="http://djangosnippets.org/snippets/2729/#c4520" rel="noreferrer">Django snippets</a> and as a <a href="https://gist.github.com/2344345/8713ee2d498ef9d0263a53e4c367aa3507a57d81" rel="noreferrer">GitHub gist</a>.</p>