Skip to content

Developer notes

ms-info edited this page Jan 19, 2013 · 10 revisions

Creating your local MySQL database

mysql> CREATE DATABASE ccvote CHARACTER SET UTF8;
mysql> CREATE USER 'vote_db_user'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL ON ccvote.* TO 'vote_db_user'@'localhost';

Ignoring Localized settings.py

So, once a file's already in a repo, you can't ".gitignore" it. But, you can apparently "assume-unchanged" a file to tell it not to push your changes to the main server.

From: http://stackoverflow.com/questions/7070659/git-exclude-ignore-files-from-commit

git update-index --assume-unchanged ccvote/ccvote/settings.py

Updating your ccvote/settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'ccvote',                # Or path to database file if using sqlite3.
        'USER': 'vote_db_user',          # Not used with sqlite3.
        'PASSWORD': 'password',          # Not used with sqlite3.
        'HOST': 'localhost',             # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}
TIME_ZONE = 'America/New_York' # Eastern time-zone
# Local directory for static file serving (e.g. /srv/www/ccvote/static/, /home/me/django/ccvote/static/)
# NOTE: Observe the use for forward slash even on windows.
# NOTE 2: This is where django *manages* static files. *You* put static files in the <app>/static 
#         directory. (e.g. ccvote/main/static/)
STATIC_ROOT = 'c:/django/ccvote/static'
STATIC_URL = '/static/'
TEMPLATE_DIRS = (
     'c:/path-to-your/ccvote/templates',
)
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',       
    'django.contrib.sessions',           
    'django.contrib.sites',              
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    # 
    # The "main" app must be added!
    #
    'main',
)

Resetting the DB

WARNING: Use with caution

$ python manage.py sqlclear main admin sites sessions auth contenttypes | python manage.py dbshell
$ python manage.py syncdb

Resetting your admin password

If you have forgotten the Django admin password you can reset it easily with manage.py

$ python manage.py changepassword