{ "info": { "author": "RED Interactive Agency", "author_email": "geeks@ff0000.com", "bugtrack_url": null, "classifiers": [], "description": "An application to bootstrap \n\nFrequently we need to create a Django project from scratch and push it on a production machine. \n**pypeton** helps reduce the number of manual steps to achieve this goal.\n\n\n## Installation\n \n pip install -e git+git://github.com/ff0000/pypeton.git\n\n\n## Usage\n\n pypeton [options] project_name\n \n### Options\n\n --version show program's version number and exit\n -h, --help show this help message and exit\n -v, --virtualenv initialise virtual envirnment\n -s, --subversion create project in svn style with trunk/tags/branches\n -d DIR, --dir=DIR base project directory\n -e ENV, --env=ENV [django]\n \n### Examples\n\nMost basic project\n\n pypeton my_project\n \n \nBuild out an svn folder structure, insert a django project into trunk, and \ninitialize a virtual environment all in one step.\n\n pypeton -s -v my_project \n \nSpecify a directory other than the present working directory\n\n pypeton -d /path/to/folder my_project\n \n \n## TODO: \n\nAdd description of project customization:\n\n* how to define requirements\n* what's in which folder\n\n\n\n## Installing requirements\n\nThe next step is to install the requirements for the project, with these commands:\n\n cd fooapp/trunk\n source activate\n cd project\n ./manage.py require\n\nwhere `./manage.py require` is a provided shortcut for `pip install -r ../deploy/requirements.txt && pip install -r ../deploy/requirements/development.txt`.\n\n## Running the project in the browser\n\nThe project comes with an empty home-page which can be seen in a web browser by running:\n\n ./manage.py syncdb\n ./manage.py server\n\nand then opening [http://localhost:8000/](http://localhost:8000/) in a browser window. `./manage.py server` is a shortcut provided for the command `./manage.py runserver 0.0.0.0:8000` used frequently to start the local server.\n\n## Resetting the database and loading fixtures\n \nThe project also comes with an application named *initial_data*, a model with a fixture to create in the development environment an *admin* user with password *admin* and a site called http://example.com:8000. These data can be loaded by running:\n\n ./manage.py sync\n\nwhere `./manage.py sync` is a shortcut to:\n\n* reset the database structure \n* synchronize it again with the latest models\n* optionally reload the fixtures for the specified environment (in this case, users and sites for development)\n\nAt this point, Django admin can be accessed by running `./manage.py server` again, then logging into [http://example.com:8000/admin](http://example.com:8000/admin) with admin/admin (make sure to have \"example.com\" in the machine hosts file pointing to the localhost).\n\n## Creating a new model and application\n\nA new model (e.g., called *Picture*) can be created with the command:\n\n ./sta Picture\n\nwhich extends the default \"./manage.py startapp\" command by delivering a coherent file structure and providing two basic views for index and show. To include this model in the application:\n\n* add `'pictures',` to `INSTALLED_APPS` in settings/\\_\\_init\\_\\_.py, and\n* add `(r'^pictures/', include('pictures.urls'))` to `urlpatterns` in urls.py.\n* run `./manage.py sync` to add the model to the database\n\nAt this point, all these new views become available:\n\n* http://example.com:8000/admin/pictures/picture/add/ (to add a picture)\n* http://example.com:8000/admin/pictures/picture/ (to admin the pictures)\n* http://example.com:8000/pictures/ (to show the list of pictures)\n* http://example.com:8000/pictures/1/ (to show one picture after its creation)\n\n## Customizing the model\n\nThe newly created model can be edited at will. For instance, the Picture model can be inherited by [django-imagekit](https://github.com/jdriscoll/django-imagekit)'s ImageModel in order to have many image-related functions available. For this purpose:\n\n\n\n* add the following lines to deploy/requirements.txt:\n\n pil # to use models.ImageField\n django-imagekit # to deal with image size, thumbnails\n\n* run the command `./manage.py require` to install the new requirements\n\n* edit apps/pictures/models.py to begin as:\n\n from django.db import models\n from imagekit.models import ImageModel\n \n class Picture(ImageModel):\n name = models.CharField(max_length=255)\n image = models.ImageField(upload_to='pictures')\n num_views = models.PositiveIntegerField(editable=False, default=0)\n #\n class IKOptions:\n # This inner class is where we define the ImageKit options for the model\n spec_module = 'pictures.specs'\n cache_dir = 'cache'\n image_field = 'image'\n save_count_as = 'num_views'\n \n* add apps/pictures/specs.py as:\n\n from imagekit.specs import ImageSpec\n from imagekit import processors\n \n # first we define our thumbnail resize processor\n class ResizeThumb(processors.Resize):\n width = 20\n height = 20\n crop = True\n \n # now we can define our thumbnail spec\n class Thumbnail(ImageSpec):\n access_as = 'thumbnail_image'\n pre_cache = True\n processors = [ResizeThumb]\n \n* change the loop in template/pictures/index.html as:\n\n {% for picture in pictures %}\n