Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 2.13 KB

README.md

File metadata and controls

72 lines (51 loc) · 2.13 KB

Contained herein is some stuff I've found useful when setting up new Django projects.

You'll need to set up proto_django/settings/local_settings.py, but to review/find the variables you need to set you can run python manage.py test proto_django.tests until you don't get any errors.

Prerequisites

  • Postgres
  • Python 2.7
  • RabbitMQ
  • virtualenv and virtualenv-wrapper

Customizing for your environment

  1. Rename the project:

     PROJECT_NAME=example
     find * -type f -print0 | xargs -0 perl -i.bak -pe "s|proto_django|$PROJECT_NAME|g"
     find . -name '*.bak' -exec rm {} \;
     mv proto_django $PROJECT_NAME
    
  2. Set up rabbitmq:

     PROJECT_NAME=example
     RABBIT_USER=$PROJECT_NAME
     RABBIT_VHOST=$PROJECT_NAME
     RABBIT_PASS=
     sudo rabbitmqctl add_user $RABBIT_USER $RABBIT_PASS
     sudo rabbitmqctl add_vhost $RABBIT_VHOST
     sudo rabbitmqctl set_permissions -p $RABBIT_VHOST $RABBIT_USER '.*' '.*' '.*'
    
  3. Install binaries:

  • postgresql server
  • graphviz and graphviz-devel
  1. Install virtualenv and modules so that you can have Django:

     make virtualenv
     workon $PROJECT_NAME
    
  2. Generate a SECRET_KEY for your local settings:

     from django.utils.crypto import get_random_string
     
     chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
     get_random_string(50, chars)
    
  3. Set up your local_settings.py in $PROJECT_NAME/settings/local_settings.py:

     SECRET_KEY = u'CONTENTS-FROM-THE-ABOVE-STEP'
     BROKER_URL = "" # have the shell echo "amqp://$RABBIT_USER:$RABBIT_PASS@localhost/$RABBIT_VHOST"
     CELERY_RESULT_BACKEND = "amqp"
     CELERY_CONCURRENCY = 1
     CELERYD_NODES = "w1"
    
     # Example:
     DATABASES = {    'default': {
             'ENGINE': 'django.db.backends.postgresql_psycopg2',
             'NAME': 'DATABASE-NAME',
             'USER': 'DATABASE-USER',
             'PASSWORD': 'DATABASE-PASS',
             'HOST': 'DATABASE-HOST',
             'PORT': 'DATABASE-PORT',
         }
     }
    
  4. Remove proto_django from the git remote list:

     git remote rm origin