-
Notifications
You must be signed in to change notification settings - Fork 12
Development
First clone the repository.
You have to have python3 in your $PATH. Production version is running on 3.6, but anything 3.2+ should work, although not tested at all.
To prepare an environment, the script in bin/init-run.sh is prepared for you (it's quite short). You need to run it only once. It should create a virtual environment and install all necessary packages in it. You could run those commands on your own as well, if anything goes wrong.
Then go to website directory, activate the environment source .venv/bin/activate and run python manage.py runserver. Now you should be up and running on 127.0.0.1:8000. When you kill the server by CTRL+C, you can invoke it again by python manage.py runserver.
The database will be empty and you won't see e.g. menus as you can see in a production version on http://efektivni-altruismus.cz! This is because menus, posts and others are considered as a dynamic content stored in the production database. Ask Daniel for a copy of it, since he is the only one with access to production server. We don't have it versioned here for security reasons (but it is backed up of course). When you obtain it, save it as dev-eacr.sqlite3, run python manage.py createsuperuser and choose whatever credentials you want (will be needed later).
When you try to access 127.0.0.1:8000/admin, you are very probably going to see an error site matching query does not exist or NoneType does not have attribute objects. This can be solved by adding the current site e.g. something.efektivni-altruismus.cz to your /etc/hosts (or a variant of it for your OS, e.g. on windows it should be %SystemRoot%\System32\drivers\etc\hosts or something):
127.0.0.1 efektivni-altruismus.cz
127.0.0.1 cfar.efektivni-altruismus.cz
127.0.0.1 effectivethesis.com
127.0.0.1 pomahej-efektivne.efektivni-altruismus.cz
So after theses steps:
- cloning repository
- installing dependencies
- obtaining database
- adding domains to
/etc/hosts - creating superuser
you should be able to go to e.g. efektivni-altruismus.cz:8000 in your browser and see a local version of the site. Go to /admin to get into the admin - use the superuser's credentials you used before.
The site is using python wagtail CMS and Bootstrap 4.
Everything regarding the site itself is in website directory. eacr directory contains settings file in settings/settings.py and also a static directory with all the static assets (CSS, JS, static imgs).
Templating is easy. There is eacr/templates/base.html, which is super important. homepage template in home/templates/home_page.html inherits from the base.html and blog/templates/* inherits from `homepage.html.
There is quite good wagtail documentation. Otherwise it is regular django project, so more about e.g. django templates is here.
We have a single setting file and the configuration for different environment (production, beta, development, ...) are set up by appropriate environment variables. For development, there are sensible defaults in eacr/settings.py, so you don't have to do anything extra.
But e.g. in production, we do bin/production-env.sh. You can source all variables from a file by:
set -a
source bin/production-env.sh
set +a
and then run a server by python manage.py runserver as usual.
As for system dependencies, you may need some additional libraries for pillow, but I think it is not needed for development.