Skip to content

Latest commit

 

History

History
141 lines (106 loc) · 2.8 KB

README.md

File metadata and controls

141 lines (106 loc) · 2.8 KB

Luke

Simple scripts and templates for scaffolding a basic Django project

Prerequisites

Usage

  1. Download the repository's tarball and extract it to your project's directory

    $ mkdir myproject
    $ cd myproject
    $ wget https://github.com/vinco/luke/archive/master.tar.gz -O - | tar -xz --strip 1
  2. Set your project's name in evironments.json, fabfile.py and provision/provision.sh

    # myproject/environments.json
    {
        "vagrant": {
            "django_settings": "myproject.settings.local",
        }
    }
    # myproject/fabfile.py
    ...
    # urun('createdb luke -l en_US.UTF-8 -E UTF8 -T template0')
    urun('createdb myproject -l en_US.UTF-8 -E UTF8 -T template0')
    ... 
    # urun('dropdb luke')
    urun('dropdb myproject')
    ...
    # myproject/provision/provision.sh
    ...
    # PROJECT_NAME=luke
    PROJECT_NAME=myproject
    ...
  3. Create the virtual machine

    $ vagrant up
  4. Redirect the required domains to your localhost

    # /etc/hosts
    192.168.33.2  http://luke.local/
  5. Build the environment inside the virtual machine

    $ fab environment:vagrant bootstrap
  6. Add the following in the file myproject/urls.py for configure django debug toolbar

    from django.conf import settings
    
    if settings.DEBUG:
        import debug_toolbar
        urlpatterns += [
            url(r'^__debug__/', include(debug_toolbar.urls)),
        ]
  7. Run the development server

    $ fab environment:vagrant runserver
  8. Init your repository

    $ git init

Testing

  1. Set your project's name in tox.ini.

    # change name
    application-import-names = myproject
    
    DJANGO_SETTINGS_MODULE = myproject.settings.testing
    
    norecursedirs =
        .*
        src/requirements
        src/myproject/settings
  2. Open vagrant environment from ssh:

    $ vagrant ssh
  3. Change directory to /vagrant:

    $ cd /vagrant
  4. Install tox inside the virtual machine:

    $ pip install tox
  5. Run the proper command with tox:

# Run the full test suite including the PEP8 linter.
$ tox

# Run only the PEP8 linter.
$ tox -e py27-flake8

# Run only the test suite.
$ tox -e py27-django

# Pass -r flag to recreate the virtual environment when requirements changes.
$ tox -r

# Run the test suite to a specific file.
$ tox -e py27-django src/luke/core/api/tests/test_serializers.py