├── djangoproj ├── core │ ├── __init__.py │ ├── urls.py │ ├── wsgi.py │ └── settings.py └── manage.py ├── .gitignore ├── README.md └── setup.sh /djangoproj/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#*# 3 | .#* 4 | -------------------------------------------------------------------------------- /djangoproj/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /djangoproj/core/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, include, url 2 | 3 | # Uncomment the next two lines to enable the admin: 4 | from django.contrib import admin 5 | admin.autodiscover() 6 | 7 | urlpatterns = patterns('', 8 | # Examples: 9 | # url(r'^$', 'djangoproj.views.home', name='home'), 10 | # url(r'^djangoproj/', include('djangoproj.foo.urls')), 11 | 12 | # Uncomment the admin/doc line below to enable admin documentation: 13 | url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 14 | 15 | # Uncomment the next line to enable the admin: 16 | url(r'^admin/', include(admin.site.urls)), 17 | ) 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Creates an empty Django project in an [uberspace](http://uberspace.de/). 4 | 5 | ## Features 6 | 7 | * virtualenv 8 | * Django Admin enabled 9 | * nice URLs (rewrite) 10 | * ipython 11 | 12 | # Usage 13 | 14 | * Create an account at uberspace and login: 15 | 16 | ``` 17 | $ ssh USERNAME@HOST.uberspace.de 18 | ``` 19 | 20 | * Clone the uberdjango repository into your uberspace: 21 | 22 | ``` 23 | $ git clone https://github.com/buzz/uberdjango.git 24 | $ cd uberdjango 25 | ``` 26 | 27 | * Run the setup script: 28 | 29 | ``` 30 | ./setup.sh DJANGOPROJECT 31 | ``` 32 | 33 | `DJANGOPROJECT` will be your Django project name (only numbers, letters and underscores). Surf to `http://USERNAME.HOST.uberspace.de/admin`, login and change your admin password. 34 | 35 | Happy coding :) 36 | -------------------------------------------------------------------------------- /djangoproj/core/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for djangoproj project. 3 | 4 | This module contains the WSGI application used by Django's development server 5 | and any production WSGI deployments. It should expose a module-level variable 6 | named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover 7 | this application via the ``WSGI_APPLICATION`` setting. 8 | 9 | Usually you will have the standard Django WSGI application here, but it also 10 | might make sense to replace the whole Django WSGI application with a custom one 11 | that later delegates to the Django one. For example, you could introduce WSGI 12 | middleware here, or combine a Django application with an application of another 13 | framework. 14 | 15 | """ 16 | import os 17 | 18 | # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks 19 | # if running multiple sites in the same mod_wsgi process. To fix this, use 20 | # mod_wsgi daemon mode with each site in its own daemon process, or use 21 | # os.environ["DJANGO_SETTINGS_MODULE"] = "djangoproj.settings" 22 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoproj.settings") 23 | 24 | # This application object is used by any WSGI server configured to use this 25 | # file. This includes Django's development server, if the WSGI_APPLICATION 26 | # setting points here. 27 | from django.core.wsgi import get_wsgi_application 28 | application = get_wsgi_application() 29 | 30 | # Apply WSGI middleware here. 31 | # from helloworld.wsgi import HelloWorldApplication 32 | # application = HelloWorldApplication(application) 33 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 1 ] 4 | then 5 | echo "Usage: `basename $0` DJANGO_PROJECT_NAME" 6 | exit -1 7 | fi 8 | 9 | project=$1 10 | 11 | # fcgi wrapper 12 | cat <~/fcgi-bin/${project} 13 | #!/usr/bin/env python2.7 14 | import sys, os 15 | 16 | HOME = os.path.expanduser('~') 17 | ACTIVATE_THIS = '%s/venv/bin/activate_this.py' % HOME 18 | DJANGO_PROJECT = '%s/${project}' % HOME 19 | logfile = open('%s/fcgi-error.log' % HOME, 'a') 20 | 21 | try: 22 | # Setup env 23 | execfile(ACTIVATE_THIS, dict(__file__ = ACTIVATE_THIS)) 24 | sys.path.insert(0, DJANGO_PROJECT) 25 | os.chdir(DJANGO_PROJECT) 26 | os.environ['DJANGO_SETTINGS_MODULE'] = 'core.settings' 27 | 28 | # Start 29 | from django.core.servers.fastcgi import runfastcgi 30 | runfastcgi(method='threaded', daemonize='false') 31 | except: 32 | import traceback 33 | traceback.print_exc(file=logfile) 34 | EOF 35 | chmod 755 ~/fcgi-bin/${project} 36 | 37 | # apache rewrite rules 38 | cat <~/html/.htaccess 39 | RewriteEngine on 40 | RewriteCond %{REQUEST_FILENAME} !-f 41 | RewriteRule ^(.*)$ /fcgi-bin/${project}/\$1 [QSA,L] 42 | EOF 43 | 44 | pushd ~ 45 | easy_install virtualenv 46 | virtualenv -p `which python2.7` venv 47 | source venv/bin/activate 48 | 49 | echo "source venv/bin/activate" >> .bashrc 50 | echo "alias manage='python ~/${project}/manage.py'" >> .bashrc 51 | 52 | # install django 53 | pip install django 54 | pip install south 55 | pip install flup 56 | 57 | # install ipython for proper "$ manage shell" 58 | pip install readline 59 | pip install ipython 60 | 61 | # copy static admin files 62 | mkdir -p ~/html/static 63 | cp -a ~/venv/lib/python2.7/site-packages/django/contrib/admin/static/admin ~/html/static/ 64 | 65 | # init django project 66 | popd 67 | cp -R djangoproj ~/${project} 68 | pushd ~/${project} 69 | python manage.py syncdb --noinput 70 | pwd=`openssl passwd "$RANDOM" | cut -c1-8` 71 | export DJANGO_SETTINGS_MODULE="core.settings" 72 | echo "from django.contrib.auth import models as auth_models; auth_models.User.objects.create_superuser('admin', 'admin@example.com', '${pwd}')" | python 73 | 74 | echo "************************************************" 75 | echo "Django project ${project} is up 'n running..." 76 | echo "Login as admin, password: ${pwd}" 77 | echo "Surf to http://$(whoami).$(hostname)/admin" 78 | echo "************************************************" 79 | -------------------------------------------------------------------------------- /djangoproj/core/settings.py: -------------------------------------------------------------------------------- 1 | # Django settings for djangoproj project. 2 | 3 | from os.path import join, dirname 4 | 5 | DEBUG = True 6 | TEMPLATE_DEBUG = DEBUG 7 | 8 | ADMINS = ( 9 | # ('Your Name', 'your_email@example.com'), 10 | ) 11 | 12 | MANAGERS = ADMINS 13 | 14 | DATABASES = { 15 | 'default': { 16 | 'ENGINE': 'django.db.backends.sqlite3', 17 | 'NAME': join(dirname(dirname(__file__)), 'db.sqlite3'), 18 | # The following settings are not used with sqlite3: 19 | 'USER': '', 20 | 'PASSWORD': '', 21 | 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 22 | 'PORT': '', # Set to empty string for default. 23 | } 24 | } 25 | 26 | # Hosts/domain names that are valid for this site; required if DEBUG is False 27 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts 28 | ALLOWED_HOSTS = [] 29 | 30 | # Local time zone for this installation. Choices can be found here: 31 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 32 | # although not all choices may be available on all operating systems. 33 | # In a Windows environment this must be set to your system time zone. 34 | TIME_ZONE = 'Europe/Berlin' 35 | 36 | # Language code for this installation. All choices can be found here: 37 | # http://www.i18nguy.com/unicode/language-identifiers.html 38 | LANGUAGE_CODE = 'en-us' 39 | 40 | SITE_ID = 1 41 | 42 | # If you set this to False, Django will make some optimizations so as not 43 | # to load the internationalization machinery. 44 | USE_I18N = True 45 | 46 | # If you set this to False, Django will not format dates, numbers and 47 | # calendars according to the current locale. 48 | USE_L10N = True 49 | 50 | # If you set this to False, Django will not use timezone-aware datetimes. 51 | USE_TZ = True 52 | 53 | # Absolute filesystem path to the directory that will hold user-uploaded files. 54 | # Example: "/var/www/example.com/media/" 55 | MEDIA_ROOT = '' 56 | 57 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a 58 | # trailing slash. 59 | # Examples: "http://example.com/media/", "http://media.example.com/" 60 | MEDIA_URL = '' 61 | 62 | # Absolute path to the directory static files should be collected to. 63 | # Don't put anything in this directory yourself; store your static files 64 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. 65 | # Example: "/var/www/example.com/static/" 66 | STATIC_ROOT = '' 67 | 68 | # URL prefix for static files. 69 | # Example: "http://example.com/static/", "http://static.example.com/" 70 | STATIC_URL = '/static/' 71 | 72 | # Additional locations of static files 73 | STATICFILES_DIRS = ( 74 | # Put strings here, like "/home/html/static" or "C:/www/django/static". 75 | # Always use forward slashes, even on Windows. 76 | # Don't forget to use absolute paths, not relative paths. 77 | ) 78 | 79 | # List of finder classes that know how to find static files in 80 | # various locations. 81 | STATICFILES_FINDERS = ( 82 | 'django.contrib.staticfiles.finders.FileSystemFinder', 83 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 84 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', 85 | ) 86 | 87 | # Make this unique, and don't share it with anybody. 88 | SECRET_KEY = '+%qk#v*hyv^t_sfp4g4+7gglbwgl6%&*wd+!l9boxq*ybz*-tm' 89 | 90 | # List of callables that know how to import templates from various sources. 91 | TEMPLATE_LOADERS = ( 92 | 'django.template.loaders.filesystem.Loader', 93 | 'django.template.loaders.app_directories.Loader', 94 | # 'django.template.loaders.eggs.Loader', 95 | ) 96 | 97 | MIDDLEWARE_CLASSES = ( 98 | 'django.middleware.common.CommonMiddleware', 99 | 'django.contrib.sessions.middleware.SessionMiddleware', 100 | 'django.middleware.csrf.CsrfViewMiddleware', 101 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 102 | 'django.contrib.messages.middleware.MessageMiddleware', 103 | # Uncomment the next line for simple clickjacking protection: 104 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 105 | ) 106 | 107 | ROOT_URLCONF = 'core.urls' 108 | 109 | # Python dotted path to the WSGI application used by Django's runserver. 110 | WSGI_APPLICATION = 'core.wsgi.application' 111 | 112 | TEMPLATE_DIRS = ( 113 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 114 | # Always use forward slashes, even on Windows. 115 | # Don't forget to use absolute paths, not relative paths. 116 | ) 117 | 118 | INSTALLED_APPS = ( 119 | 'django.contrib.auth', 120 | 'django.contrib.contenttypes', 121 | 'django.contrib.sessions', 122 | 'django.contrib.sites', 123 | 'django.contrib.messages', 124 | 'django.contrib.staticfiles', 125 | # Uncomment the next line to enable the admin: 126 | 'django.contrib.admin', 127 | # Uncomment the next line to enable admin documentation: 128 | 'django.contrib.admindocs', 129 | 'south' 130 | ) 131 | 132 | SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' 133 | 134 | # A sample logging configuration. The only tangible logging 135 | # performed by this configuration is to send an email to 136 | # the site admins on every HTTP 500 error when DEBUG=False. 137 | # See http://docs.djangoproject.com/en/dev/topics/logging for 138 | # more details on how to customize your logging configuration. 139 | LOGGING = { 140 | 'version': 1, 141 | 'disable_existing_loggers': False, 142 | 'filters': { 143 | 'require_debug_false': { 144 | '()': 'django.utils.log.RequireDebugFalse' 145 | } 146 | }, 147 | 'handlers': { 148 | 'mail_admins': { 149 | 'level': 'ERROR', 150 | 'filters': ['require_debug_false'], 151 | 'class': 'django.utils.log.AdminEmailHandler' 152 | } 153 | }, 154 | 'loggers': { 155 | 'django.request': { 156 | 'handlers': ['mail_admins'], 157 | 'level': 'ERROR', 158 | 'propagate': True, 159 | }, 160 | } 161 | } 162 | --------------------------------------------------------------------------------