Simple scripts and templates for scaffolding a basic Django project
-
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
-
Set your project's name in
evironments.json
,fabfile.py
andprovision/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 ...
-
Create the virtual machine
$ vagrant up
-
Redirect the required domains to your localhost
# /etc/hosts 192.168.33.2 http://luke.local/
-
Build the environment inside the virtual machine
$ fab environment:vagrant bootstrap
-
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)), ]
-
Run the development server
$ fab environment:vagrant runserver
-
Init your repository
$ git init
-
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
-
Open vagrant environment from ssh:
$ vagrant ssh
-
Change directory to
/vagrant
:$ cd /vagrant
-
Install tox inside the virtual machine:
$ pip install tox
-
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