/tbpweb

TBP CA-A website rework

Primary LanguagePython

tbpweb

TBP CA-A website rework, build in Django

Setup

Vagrant will automatically setup a virtual machine with the correct setup for developing hknweb.

Install Vagrant and VirtualBox Try to install Virtual Box 6.0.14, as there have been some issues in the past with other versions of Virtual Box in terms of compatibility of Vagrant.

Fork the tbpweb repository and clone your fork to your local machine

Open terminal, and cd into the cloned directory. Check to make sure there is a Vagrantfile in the directory. From there, type

$ vagrant up

which will download and boot a Linux virtual machine, then run setup.

To access the environment, run

$ vagrant ssh

which will ssh your terminal into the virtual machine.

See Development for how to run the Django web server.

From here, run

$ cd tbpweb

Developing on tbpweb requires a virtual environment so that every developer has the exact same development environment i.e. any errors that a developer has is not due to difference in configuration. We will be using Python's built-on venv to make our virtual environment. This command creates our virtual environment.

$ make venv

Next, we need to have our current terminal/shell use the virtual environment we just created. We do this through:

$ source .venv/bin/activate

To install all dependencies (including django), run

$ make install

There may be warnings that installation of some packages failed, but as long as you can run the command below successfully you are good to go.

If you make any Django changes (to the database models, for instance) you will have to create and migrate migrations. You can do so with the command below. If there were changes to database models made by other developers and you pulled those changes, you just have to run make migrate.

$ make migrations
$ make migrate

If you would like to access the admin interface, create a superuser using the command

$ make superuser

Finally, to run the web instance, simply run the command

$ make run

This will start the development server at http://0.0.0.0:3000/. If you go into your web browser and access localhost:3000, you should be able to see the site now!

To access the admin site, access http://0.0.0.0:3000/admin. Use the credentials you created for your superuser to login.

To exit out of the pipenv shell, run

$ exit

The same command can be used to exit out of the virtual machine ssh connection.

To turn off the virtual machine, run

$ vagrant halt

which will attempt to safely shutdown the virtual machine, or kill it otherwise.