Skip to content

Instantly share code, notes, and snippets.

@bittner
Last active August 29, 2015 13:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bittner/8951691 to your computer and use it in GitHub Desktop.
Quick test project generator for Django package development
#!/bin/bash
# Make sure you've created a VirtualEnv beforehand: $ mkvirtualenv test && workon test
# @author Peter Bittner <django@bittner.it>
# @license GPLv3, https://www.gnu.org/copyleft/gpl.html
PROJECT=ascalcio
printf 'Uninstalling Django, please wait ...'
pip uninstall -q Django
rm -rfv manage.py $PROJECT
# As an alternative to above, the following will uninstall all packages:
#pip freeze | sed 's/==.*$//' | xargs -I PKG pip uninstall -y PKG
printf 'Installing Django and setting up project '$PROJECT' ...\n'
pip install "Django<1.6" && django-admin.py startproject $PROJECT . && chmod 755 manage.py && \
printf '"""\nProject '$PROJECT' based on django Organice vx.x. http://organice.io\n"""\n' >> $PROJECT/__init__.py
mkdir $PROJECT/settings && mv $PROJECT/settings{.py,/common.py} && {
__INIT__=$PROJECT/settings/__init__.py
printf '"""\nModularized settings generated by django Organice setup. http://organice.io\n' >> $__INIT__
printf 'This solution follows the second recommendation from\n' >> $__INIT__
printf 'http://www.sparklewise.com/django-settings-for-production-and-development-best-practices/\n' >> $__INIT__
printf '"""\nfrom develop import *\n' >> $__INIT__
} && {
DEVELOP=$PROJECT/settings/develop.py
STAGING=$PROJECT/settings/staging.py
PRODUCTION=$PROJECT/settings/production.py
printf '# Django project settings for Develop environment\n\nfrom common import *\n' >> $DEVELOP
printf '# Django project settings for Staging environment\n\nfrom common import *\n' >> $STAGING
printf '# Django project settings for Production environment\n\nfrom common import *\n' >> $PRODUCTION
}
printf 'Done.\n'
[[ `which tree` ]] && tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment