Django

  • Website

  • How to create a new Django secret key

    python3 manage.py shell -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
    
  • How to run Django in the background

    nohup python manage.py runserver &
    
  • How to remove Django migrations

    python manage.py migrate --fake APPNAME zero
    

Data

  • How to dump Django data

    python manage.py dumpdata --exclude auth.permission --exclude contenttypes --indent 2 > db.json
    
  • How to restore Django data

    python manage.py loaddata db.json