-
-
Save abidibo/fa1ac31067fc5882f33e to your computer and use it in GitHub Desktop.
Starting a new python project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Environment | |
(http://www.abidibo.net/blog/2012/04/30/deploy-django-applications-nginx-uwsgi-virtualenv-south-git-and-fabric-part-1/) | |
$ cd /var/www/ | |
$ mkdir myproject | |
$ cd myproject | |
$ virtualenv --no-site-packages venv | |
$ source ./venv/bin/activate | |
$ pip install django | |
$ pip install South | |
$ pip install fabric | |
$ pip install mysql-python | |
$ pip install uwsgi | |
$ pip install django-pipeline | |
$ pip install django-ckeditor-updated | |
$ django-admin.py startproject myproject | |
# DB | |
Create mysql DB and edit settings.py | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', | |
'NAME': 'db_myproject', | |
'USER': 'root', | |
'PASSWORD': '', | |
'HOST': '', | |
'PORT': '', | |
} | |
} | |
# Static, Templates, Bootstrap | |
$ cd /var/www/myproject/myproject | |
$ mkdir static | |
$ cd myproject | |
$ mkdir static templates | |
$ cd static | |
$ mkdir myproject | |
$ cd myproject | |
$ mkdir src | |
$ cd src | |
$ mkdir fonts img js less | |
$ cd js | |
$ mkdir lib | |
Copy bootstrap and font-awesome folders inside the less folder. Copy jquery and bootstrap-min.js inside folders inside the | |
js/lib folder | |
In settings.py | |
# Templates | |
TEMPLATE_DIRS = ( | |
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | |
# Always use forward slashes, even on Windows. | |
# Don't forget to use absolute paths, not relative paths. | |
os.path.join(BASE_DIR, 'templates'), | |
) | |
# Static files (CSS, JavaScript, Images) | |
# https://docs.djangoproject.com/en/1.6/howto/static-files/ | |
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' | |
STATICFILES_FINDERS = ( | |
"django.contrib.staticfiles.finders.FileSystemFinder", | |
"django.contrib.staticfiles.finders.AppDirectoriesFinder", | |
"djangular.finders.NamespacedAngularAppDirectoriesFinder", | |
) | |
STATIC_URL = '/static/' | |
STATIC_ROOT = os.path.join(BASE_DIR, 'static') | |
STATICFILES_DIRS = ( | |
# Put strings here, like "/home/html/static" or "C:/www/django/static". | |
# Always use forward slashes, even on Windows. | |
# Don't forget to use absolute paths, not relative paths. | |
os.path.join(os.path.join(BASE_DIR, 'myproject'), 'static'), | |
) | |
# django-pipeline | |
In settings.py | |
PIPELINE_CSS = { | |
'shared': { | |
'source_filenames': ( | |
'myproject/src/less/styles.less', | |
), | |
'output_filename': 'myproject/css/stylesheet.css', | |
}, | |
} | |
PIPELINE_JS = { | |
'jquery': { | |
'source_filenames': ( | |
'myproject/src/js/lib/jquery/jquery.js', | |
'myproject/src/js/lib/bootstrap/bootstrap.min.js', | |
), | |
'output_filename': 'myproject/js/jquery-all.js' | |
} | |
} | |
PIPELINE_ENABLED = False | |
PIPELINE_COMPILERS = ( | |
'pipeline.compilers.less.LessCompiler', | |
# Media | |
$ cd /var/www/myproject/myproject | |
$ mkdir media | |
In settings.py | |
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | |
MEDIA_URL = '/media/' | |
In urls.py | |
# development media | |
urlpatterns += patterns('', | |
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), | |
) | |
# CKEditor | |
$ cd /var/www/myproject/myproject/media | |
$ mkdir ckeditor | |
In setting.py | |
CKEDITOR_UPLOAD_PATH = os.path.join(MEDIA_ROOT, 'ckeditor') | |
CKEDITOR_CONFIGS = { | |
'default': { | |
'skin': 'moono', | |
'toolbar_Basic': [ | |
['Source', '-', 'Bold', 'Italic'] | |
], | |
'toolbar_Full': [ | |
['Styles', 'Format', 'Bold', 'Italic', 'Underline', 'Strike', 'SpellChecker', 'Undo', 'Redo'], | |
['NumberedList','BulletedList'], | |
['Link','Unlink','Anchor'], | |
['Image', 'Flash', 'Table', 'HorizontalRule'], | |
['TextColor', 'BGColor'], | |
['SpecialChar'], ['PasteFromWord'], ['Source'] | |
], | |
'toolbar': 'Full', | |
'height': 291, | |
'width': 835, | |
'filebrowserWindowWidth': 940, | |
'filebrowserWindowHeight': 725, | |
'contentsCss': '/static/abidibo_net/css/styles.css' | |
} | |
} | |
In urls.py | |
url(r'^ckeditor/', include('ckeditor.urls')), | |
# Installed apps | |
In settings.py | |
# Application definition | |
INSTALLED_APPS = ( | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'django.contrib.sites', | |
'django.contrib.flatpages', | |
'south', | |
'pipeline', | |
'ckeditor', | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django settings for bancoausili project. | |
For more information on this file, see | |
https://docs.djangoproject.com/en/1.6/topics/settings/ | |
For the full list of settings and their values, see | |
https://docs.djangoproject.com/en/1.6/ref/settings/ | |
""" | |
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | |
import os | |
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | |
SITE_ID = 1 | |
# Quick-start development settings - unsuitable for production | |
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ | |
# SECURITY WARNING: keep the secret key used in production secret! | |
SECRET_KEY = '8w-x7h94+p@+w87a+!$2fl@pf=*50xrq1#ua=@35%=@7!%x8hi' | |
# SECURITY WARNING: don't run with debug turned on in production! | |
DEBUG = True | |
TEMPLATE_DEBUG = True | |
ALLOWED_HOSTS = [] | |
# Application definition | |
INSTALLED_APPS = ( | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'django.contrib.sites', | |
'django.contrib.flatpages', | |
'south', | |
'pipeline', | |
'ckeditor', | |
) | |
MIDDLEWARE_CLASSES = ( | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
) | |
ROOT_URLCONF = 'bancoausili.urls' | |
WSGI_APPLICATION = 'bancoausili.wsgi.application' | |
# Database | |
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | |
'NAME': 'db_bancoausili', # Or path to database file if using sqlite3. | |
'USER': 'root', # Not used with sqlite3. | |
'PASSWORD': '', # Not used with sqlite3. | |
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | |
'PORT': '', # Set to empty string for default. Not used with sqlite3. | |
} | |
} | |
# Internationalization | |
# https://docs.djangoproject.com/en/1.6/topics/i18n/ | |
LANGUAGE_CODE = 'it-it' | |
TIME_ZONE = 'UTC' | |
USE_I18N = False | |
USE_L10N = False | |
USE_TZ = False | |
# Templates | |
TEMPLATE_DIRS = ( | |
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | |
# Always use forward slashes, even on Windows. | |
# Don't forget to use absolute paths, not relative paths. | |
os.path.join(BASE_DIR, 'templates'), | |
) | |
# Static files (CSS, JavaScript, Images) | |
# https://docs.djangoproject.com/en/1.6/howto/static-files/ | |
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' | |
STATICFILES_FINDERS = ( | |
"django.contrib.staticfiles.finders.FileSystemFinder", | |
"django.contrib.staticfiles.finders.AppDirectoriesFinder", | |
"djangular.finders.NamespacedAngularAppDirectoriesFinder", | |
) | |
STATIC_URL = '/static/' | |
STATIC_ROOT = os.path.join(BASE_DIR, 'static') | |
STATICFILES_DIRS = ( | |
# Put strings here, like "/home/html/static" or "C:/www/django/static". | |
# Always use forward slashes, even on Windows. | |
# Don't forget to use absolute paths, not relative paths. | |
os.path.join(os.path.join(BASE_DIR, 'myproject'), 'static'), | |
) | |
# Media files (uploads) | |
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | |
MEDIA_URL = '/media/' | |
# CKEDITOR | |
CKEDITOR_UPLOAD_PATH = os.path.join(MEDIA_ROOT, 'ckeditor') | |
CKEDITOR_CONFIGS = { | |
'default': { | |
'skin': 'moono', | |
'toolbar_Basic': [ | |
['Source', '-', 'Bold', 'Italic'] | |
], | |
'toolbar_Full': [ | |
['Styles', 'Format', 'Bold', 'Italic', 'Underline', 'Strike', 'SpellChecker', 'Undo', 'Redo'], | |
['NumberedList','BulletedList'], | |
['Link','Unlink','Anchor'], | |
['Image', 'Flash', 'Table', 'HorizontalRule'], | |
['TextColor', 'BGColor'], | |
['SpecialChar'], ['PasteFromWord'], ['Source'] | |
], | |
'toolbar': 'Full', | |
'height': 291, | |
'width': 835, | |
'filebrowserWindowWidth': 940, | |
'filebrowserWindowHeight': 725, | |
'contentsCss': '/static/abidibo_net/css/styles.css' | |
} | |
} | |
# pipeline | |
PIPELINE_CSS = { | |
'shared': { | |
'source_filenames': ( | |
'bancoausili/src/less/styles.less', | |
), | |
'output_filename': 'bancoausili/css/stylesheet.css', | |
}, | |
} | |
PIPELINE_JS = { | |
'jquery': { | |
'source_filenames': ( | |
'bancoausili/src/js/lib/jquery/jquery.js', | |
'bancoausili/src/js/lib/bootstrap/bootstrap.min.js', | |
), | |
'output_filename': 'bancoausili/js/jquery-all.js' | |
} | |
} | |
PIPELINE_ENABLED = False | |
PIPELINE_COMPILERS = ( | |
'pipeline.compilers.less.LessCompiler', | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment