Skip to content

Instantly share code, notes, and snippets.

@sajadbahar
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save sajadbahar/7550284c7075816a4f0e to your computer and use it in GitHub Desktop.

Select an option

Save sajadbahar/7550284c7075816a4f0e to your computer and use it in GitHub Desktop.
wordpress -> django
#SQL to backup user data
"SELECT u.id, u.user_login AS username, u.user_pass AS
PASSWORD , u.display_name AS first_name, '' AS last_name, u.user_registered AS date_joined, "1" AS is_active, u.user_registered AS last_login, u.user_email AS email, "0" AS is_staff, "0" AS is_superuser, "1" AS email_verified, (
SELECT p.guid
FROM wp_posts p
WHERE p.post_author = u.id
AND p.post_type = 'attachment'
LIMIT 1
) AS avatar
FROM wp_users u
GROUP BY u.user_login:
#Script to add perfix to password
from apps.users.models import User
from django.contrib.auth.hashers import get_hasher
hasher = get_hasher('phpass')
users = User.objects.filter(password__startswith='$P$B')
for user in users:
user.password = hasher.from_orig(user.password)
user.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment