From caf92b7e606cef639b18e21338da338bccd189c0 Mon Sep 17 00:00:00 2001 From: Faris Date: Mon, 21 Jan 2013 12:35:50 -0800 Subject: [PATCH 1/4] Added more information about virtualenv to the readme. Added a default wsgi.py conf --- README.rst | 22 ++++++++++++++++++++-- project_name/project_name/wsgi.py | 6 ++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index c685e65c..21a54519 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,25 @@ You can choose a different name by running the same command but replacing the wo Installation of Dependencies ============================ -First, make sure you are using virtualenv (http://www.virtualenv.org). +First, make sure you are using virtualenv (http://www.virtualenv.org):: + + $ mkvirtualenv --distribute icecream + +You will also need to ensure that the virtualenv has the project directory +added to the path:: + + $ cd icecream && add2virtualenv `pwd` + +This will allow `django-admin.py` to be able to change settings using the +`--settings` flag. + +After setting up the virtualenv, be sure that the `wsgi.py` file in your +project's application folder has the correct `os.environ` set:: + + $ cd icecream/icecream/icecream && vim wsgi.py + +Change `project_name.settings.local` to your current project deployment +configuration. Then, depending on where you are installing dependencies: @@ -33,4 +51,4 @@ For production:: Acknowledgements ================ -Many thanks to Randall Degges \ No newline at end of file +Many thanks to Randall Degges diff --git a/project_name/project_name/wsgi.py b/project_name/project_name/wsgi.py index e69de29b..a960b58a 100644 --- a/project_name/project_name/wsgi.py +++ b/project_name/project_name/wsgi.py @@ -0,0 +1,6 @@ +import os + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings.local") + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() From 724566a277570eaa9a002bca0b007ee0de7348e7 Mon Sep 17 00:00:00 2001 From: Faris Date: Mon, 21 Jan 2013 14:43:44 -0800 Subject: [PATCH 2/4] add wsgi template name and urls.py file --- project_name/project_name/urls.py | 17 +++++++++++++++++ project_name/project_name/wsgi.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/project_name/project_name/urls.py b/project_name/project_name/urls.py index e69de29b..33307ef8 100644 --- a/project_name/project_name/urls.py +++ b/project_name/project_name/urls.py @@ -0,0 +1,17 @@ +from django.conf.urls import patterns, include, url + +# Uncomment the next two lines to enable the admin: +from django.contrib import admin +admin.autodiscover() + +urlpatterns = patterns('', + # Examples: + # url(r'^$', '{{ project_name }}.views.home', name='home'), + # url(r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')), + + # Uncomment the admin/doc line below to enable admin documentation: + # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), + + # Uncomment the next line to enable the admin: + url(r'^admin/', include(admin.site.urls)), +) diff --git a/project_name/project_name/wsgi.py b/project_name/project_name/wsgi.py index a960b58a..a9fd84f4 100644 --- a/project_name/project_name/wsgi.py +++ b/project_name/project_name/wsgi.py @@ -1,6 +1,6 @@ import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings.local") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings.local") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() From 4f3bde06607b5aeff566800cff9d983dd095169d Mon Sep 17 00:00:00 2001 From: Faris Date: Tue, 22 Jan 2013 13:59:41 -0800 Subject: [PATCH 3/4] added instructions for windows platform and more precise instructions for virtualenv wrapper --- README.rst | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 21a54519..c35d288a 100644 --- a/README.rst +++ b/README.rst @@ -21,20 +21,32 @@ First, make sure you are using virtualenv (http://www.virtualenv.org):: $ mkvirtualenv --distribute icecream You will also need to ensure that the virtualenv has the project directory -added to the path:: +added to the path. Adding the project directory will allow `django-admin.py` to be able to change settings using the `--settings` flag. + +In Linux and Mac OSX, you can install virtualenvwrapper (http://http://virtualenvwrapper.readthedocs.org/en/latest/), which will take care of adding the project path to the `site-directory` for you:: $ cd icecream && add2virtualenv `pwd` -This will allow `django-admin.py` to be able to change settings using the -`--settings` flag. +In Windows, or if you're not comfortable using the command line, you will need +to add a `.pth` file to the `site-packages` of your virtualenv. If you have +been following the book's example for the virtualenv directory (pg. 12), then +you will need to add a python pathfile named `_virtualenv_path_extensions.pth` +to the `site-packages`. If you have been following the book, then your +virtualenv folder will be something like:: + +`~/.virtualenvs/icecream/lib/python2.7/site-directory/` -After setting up the virtualenv, be sure that the `wsgi.py` file in your -project's application folder has the correct `os.environ` set:: +In the pathfile, you will want to include the following code (from +virtualenvwrapper):: - $ cd icecream/icecream/icecream && vim wsgi.py +```python +import sys; sys.__plen = len(sys.path) +/home//icecream/icecream/ +import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) +``` -Change `project_name.settings.local` to your current project deployment -configuration. +Virtualenvwrapper takes care of this for you by creating the exact same file +using the `add2virtualenv` command (see above). Then, depending on where you are installing dependencies: From a53a7c89af3d4d757a03e160adae3fb321591cb6 Mon Sep 17 00:00:00 2001 From: Faris Date: Tue, 22 Jan 2013 14:00:16 -0800 Subject: [PATCH 4/4] my humble addition to the Contributors file --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 8b27af4b..ee2e8cd2 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -1,3 +1,4 @@ Audrey Roy Daniel Greenfeld Juan Riaza +Faris Chebib