Django Development Mode Configuration
Django Dependencies
You will need the Ubuntu package python-pip
and use Pip to install the django
framework with the command pip install django
.
App Setup
For the application itself, you probably want to to the setup and execution as the vagrant user, not root. You can set the user
and working directory for a command like this:
execute 'some command' do
user 'ubuntu'
cwd '/home/ubuntu/project/mysite'
command 'some_command'
end
You will need the recipe to do the database migration and run the server. Database migration is done just like you did by hand.
To run the server, you have to convince the development server to listen to external ports, and to not die off after the Chef recipe is done. The command to run in the background like that will be like this:
nohup python ./manage.py runserver 0:8000 2>/dev/null &
You can do this in your Chef recipe for development (but it isn't a very good way to run something for production, since it won't restart if the server reboots).
Initial Data
You can create some data in your database by hand and then create a JSON file containing that in your repository:
python manage.py dumpdata --format=json --indent=2 polls > initial_data.json
Once that's done, you can add the initial_data.json
file to your repository, and load the fixture as part of your configuration. Hint: manage.py loaddata
.