GithubHelp home page GithubHelp logo

torchbox / vagrant-django-template Goto Github PK

View Code? Open in Web Editor NEW
238.0 238.0 85.0 242 KB

Skeleton project for a Django app running under Vagrant

License: Other

Python 51.59% Shell 36.89% HTML 11.52%

vagrant-django-template's Introduction

vagrant-django-template

A template for new Django 1.9 projects developed under Vagrant. Features offered include:

  • A Vagrantfile for building an Ubuntu Trusty based VM
  • A virtualenv (configured to be active on login), with project dependencies managed through a requirements.txt file
  • A PostgreSQL database (with the same name as the project, pre-configured in the project settings file)
  • Separation of configuration settings into base.py, dev.py and production.py (and optionally local.py, kept outside of version control) as per http://www.sparklewise.com/django-settings-for-production-and-development-best-practices/
  • django-compressor and django-debug-toolbar out of the box
  • A boilerplate base template with jquery included, and various other ideas and best practices borrowed from https://github.com/h5bp/html5-boilerplate

Setup

Install Django 1.9 on your host machine. (Be sure to explicitly uninstall earlier versions first, or use a virtualenv - having earlier versions around seems to cause pre-1.4-style settings.py and urls.py files to be generated alongside the new ones.)

To start a new project, run the following commands:

django-admin.py startproject --template https://github.com/torchbox/vagrant-django-template/zipball/master --name=Vagrantfile myproject
cd myproject
rm LICENSE  # or amend for your own purposes
vagrant up
vagrant ssh
  (then, within the SSH session:)
./manage.py runserver 0.0.0.0:8000

This will make the app accessible on the host machine as http://localhost:8000/ . The codebase is located on the host machine, exported to the VM as a shared folder; code editing and Git operations will generally be done on the host.

See also

https://github.com/torchbox/vagrant-django-base - a recipe for a Vagrant base box that can be used in place of precise32 in the Vagrantfile - this has more of the server setup baked in, so that we can save time by not having to re-run those steps every time we create a new VM instance.

vagrant-django-template's People

Contributors

boblannon avatar gasman avatar kaedroho avatar nealtodd avatar nimasmi avatar se1exin avatar vccabral avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vagrant-django-template's Issues

Some possible additions

In requirements.txt:
gunicorn==0.17.4
fabric==1.6.1

Gunicorn seems common for staging (not sure what the preference is for production). Fabric is just useful.

In project_name/settings/production.py:

ALLOWED_HOSTS = [] #Add your production site's hostname(s) here

This needed to be added before the site would run, on django-titan at least.

Error setting up virtualenv during provisioning.

Hi!
I'm getting an error when the provisioning script attempts to set up the virtualenv within the Vagrant Box.

virtualenv newproject
source newproject/bin/activate
cd newproject
pip install django==1.5.4
django-admin.py startproject --template https://github.com/torchbox/vagrant-django-template/zipball/master --name=Vagrantfile newproject
cd newproject
vagrant up

Seems that when it reaches this point:

# virtualenv setup for project
su - vagrant -c "/usr/local/bin/virtualenv $VIRTUALENV_DIR && \
    echo $PROJECT_DIR > $VIRTUALENV_DIR/.project && \
    PIP_DOWNLOAD_CACHE=/home/vagrant/.pip_download_cache $VIRTUALENV_DIR/bin/pip install -r $PROJECT_DIR/requirements.txt"

It spits out this error:

New python executable in /home/vagrant/.virtualenvs/newproject/bin/python
Installing setuptools, pip...

  Complete output from command /home/vagrant/.virtu...ewproject/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/log.py", line 9, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 2696, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 429, in __init__
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 443, in add_entry
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 1722, in find_in_zip
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 1298, in has_metadata
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 1614, in _has
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 1488, in _zipinfo_name
AssertionError: /usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/EGG-INFO/PKG-INFO is not a subpath of /usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv_support/setuptools-2.1-py2.py3-none-any.whl/
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==1.11.1', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv.py", line 824, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv.py", line 992, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv.py", line 960, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11.1-py2.7.egg/virtualenv.py", line 902, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/vagrant/.virtu...ewproject/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
-su: /home/vagrant/.virtualenvs/newproject/bin/activate: No such file or directory
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell newproject

Any idea how I might fix this?

symlink to site-packages

I'd like to have the site-packages directory (in the vagrant box) be accessible from the project root. This would make it a lot easier to view or debug third party code from the same editor I'm using for the project files. But I'm not quite sure how do this. Also, this should probably be disabled by default, e.g. commented out in install.sh if that's the place where this can be done.

Please add a License.txt file

TL;DR: Software is copyrighted by default. It needs an open source license included with the project to be open source.

I would like to use parts of this template in an open source library of mine, so contributors can easily set up their own development environment.
That library is also my pre-thesis project and the experts might be checking for copyright violations, which this is theoretically.

I assume that since you published this template on Github you are ok with people using it.

ImportError on setup and manage

It looks like the setup process is failing for me, as I seem to be getting an ImportError after vagrant up, and ./manage.py doesn't work either. Both seem to fail with the following error.

ImportError: No module named '{{ project_name }}'

Here's the output from vagrant up (identical output occurs with ./manage.py within SSH). I'm using Vagrant 1.8.1.

vagrant up is failing on apt-get installs

vagrant up is failing, as several important packages such as
libjpeg-dev libtiff-dev zlib1g-dev libfreetype6-dev liblcms2-dev postgresql libpq-dev
cannot be installed.

A fix would be highly appreciated.

Accessible on the host machine as http://localhost:8111/

Hello,

it says in your README-File, that i can connect from my host system by port 8111, but the vagrant config is set to :8000 and in my environment the client is only accessible via port 8000. Did i understand something wrong or is the README just misleading?

Thank you for your great work!

PIL

Can we have dependencies for PIL installed by default please?

It requires libjpeg-dev and just one symlink:
ln -s /usr/lib/libfreetype.so.6 /usr/lib/libfreetype.so

Still Up to Date?

Hi there, it's been a while since this project has been updated, so I wanted to ask if this is still the canonical template to develop django/vagrant projects, or if there are new templates Torchbox have made after this one (and the vagrant-django-base project as well)

Python 2.7 support

The vagrant-django-base box has only 2.6 installed. Changing that to 2.7 by default may be a problem if someone builds an older box depending on 2.6 from the base box itself, otherwise, I think it'd be a more sensible default.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.