Since Django 1.10 you can simply use get_random_secret_key in django.core.management.utils.
This will not work:
if python3: print (SECRET_KEY) else: print SECRET_KEY
because it's a syntax error in Python 3. Instead, you can just write "print (SECRET_KEY)", this works in both versions and has the same effect.