TBP CA-A website rework, build in Django
Vagrant will automatically setup a virtual machine with the correct
setup for developing hknweb
.
Install Vagrant and VirtualBox Make sure you install Virtual Box 6.0.14, as Vagrant is not compatible with newer versions of Virtual Box.
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
Make sure pipenv is installed in your virtual machine. To do this, run
$ pip3 install pipenv
Next, make sure there is a Pipfile in your current directory and run
$ pipenv shell
To install django, run
$ pipenv install django
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.