- Clone to local machine
- Run local Django server (run your own copy of the OSI website on your local machine)
- Make changes to the code
- Check if the changes are working as expected
- Push the changes to the repository
- Pull the code from the repository to the server
- Restart the server
- Clone and install requirements
git clone <repository-url>
cd osi.kaist.ac.kr
pip install -r requirements.txt # consider making a virtual environment before this step- Copy database and media files from the production server to your local project directory
WARNING - do not delete the existing database or media files. THERE ARE NO BACKUPS. Especially be careful not to overwrite them by mistake
- Copy
db.sqlite3from our production server to your local project root directory. Note thatosi.kaist.ac.kris your local project root directory. - Copy the
mediadirectory from the server to your local project root directory. Note, the production media files are in/var/www/osi.kaist.ac.kr/media.- Media files are the files uploaded by users, such as profile images, event images, etc. These are not kept in the Git repository.
- Note that static images (such as the OSI logo) are kept in the Git repository and are not in the
mediadirectory. Consider themediadirectory as an extension of the database, but for files.
- Run server
python manage.py runserverYou should see the exact same website as the production server at localhost:8000, with the same user credentials.
Try logging into your account!
-
For static text, hyperlinks, etc. in html files, you can directly change the html files in the
templatesdirectory. Note that templates can be extended (we extend all pages frombase.html) and included (we include the navbar and footer inbase.html). -
For dynamic content, you will need to change the corresponding views in
views.pyand the corresponding models inmodels.py. You should have a good understanding of Django to do this. If you are relying on this guide, you probably need to learn more about Django.
- Push your changes to GitHub
- SSH into the server
- Pull the changes from GitHub
- Restart the server
source deploy.sh # run this from the production server!
You only need to do this when setting up a new server.
- According to KAIST security practices, you need to block directory indexing (e.g., viewing list of files in
/media/). To do this, disable theIndexesoption in your Apache config at/etc/apache2/apache2.conf.<Directory /var/www/> Options -Indexes +FollowSymLinks AllowOverride None Require all granted </Directory>