Basic Wagtail-based project setup. All of our Wagtail-based project should be started on top of this.
Install Vagrant and VirtualBox:
Because sometimes our Wagtail based projects install some in-house goodies you need your Git user credentials set in your computer (you should have this anyways). Check this link to do so.
To ensure all PIP dependencies get installed smoothly, and if you need some to be installed form a Git repo, make sure your local machine has a valid Github SSH key and agent forward is enabled. Also, your Git credentials need to be setup in your machine. Your ~/.ssh/config
should be:
Host *
ForwardAgent yes
Save the changes and restart the ssh daemon:
$ launchctl stop com.openssh.sshd
$ launchctl start com.openssh.sshd
Now you're ready to clone the project and get your Vagrant machine up and running:
$ cd [my-dev-environment]
$ git clone [email protected]:joshbarr/yasha.git
$ cd yasha
$ vagrant up
[..... wait until everything gets installed]
$ vagrant ssh
$ djdev
You're done, you hero! Your instance is up and running! Available on http://localhost:8111
If your project is going to use PostgrSQL you should probably follow these guidelines:
As a PostgreSQL client you should install PgAdmin Setup a localhost connection with the forwarded 15432 port.
To init your project DB:
- Define your initials models and snippets (
core/models.py
,core/snippets.py
) - Create a new DB for your project:
createdb -Upostgres your_db_name
- Edit your DB settings in the Django settings file to be pointing to your DB
- Make your initial migration and run it:
$ ./manage.py makemigrations core
$ ./manage.py syncdb
- Uncomment the following lines from the
vagrant/provision.sh
file:
su - vagrant -c "$PYTHON $PROJECT_DIR/manage.py migrate --noinput && \
$PYTHON $PROJECT_DIR/manage.py load_initial_data && \
$PYTHON $PROJECT_DIR/manage.py update_index"
If you need to generate new fixtures, I recommend you excluding all apps except your core ones and using natural for your foreign relationships. Otherwise you're gonna enter a world of pain and misery, your choice really.
./manage.py dumpdata --indent=4 -e contenttypes -e auth.permission --natural-foreign core > core/fixtures/initial_data.json
Also, tweak the dumped fixtures to make sure your pages pks start from 1 onwards. Clean all the rubbish such as pagerevision, imagefilters etc..
Finally do your tests and commit your changes so the rest of the team can enjoy your work!
If you want to be able to connect to the PostgreSQL server in your Vagrant machine you need to edit a couple of settings. Edit /etc/postgresql/x.x/main/postgresql.conf
in the Vagrant machine and be sure you have something similar in the following line:
listen_addresses = '*' # what IP address(es) to listen on;
Then edit /etc/postgresql/9.3/main/pg_hba.conf
(also in the Vagrant machine) and check you have something like this at the end of the file:
# Database administrative login by UNIX sockets
local all postgres trust
# TYPE DATABASE USER CIDR-ADDRESS METHOD
local all all trust
host all all 10.0.2.2/24 trust
host all all 127.0.0.1/32 trust
If you're not in the office or you don't have access to the VagrantBox, try to change the link in the Vagrantfile
:
config.vm.box_url = "https://www.dropbox.com/s/e229abqxjkeaj8o/wagtail-base-v0.3.box?dl=1"
If at some point you want to restore your pre-cooked DB, run your vagrant forcing the provision:
$ vagrant up --provision
Check our guidelines on deployment