Local Development Environmentο
Warning
This setup is not intended for production environments and do not follow these steps in UAT, DEV, PROD or any other non local environments. The local/settings.py
file contains a secret_key which will be a security concern.
Contents:
Prerequsitesο
Install python 3.7+ο
Run the following command to check the installed python versionpython3 --version
If you have not installed Python 3.7+ on your local machine, head over to https://www.python.org/downloads/ and download latest version of Python.
Install Gitο
Run the following command to check the installed git version.git --version
If you have not installed Git on your local machine, head over to https://git-scm.com/downloads and download the latest version of Git.
Install pipο
Run the following command to check the installed pip version.pip3 --version
If you have not installed Pip on your local machine, head over to https://pip.pypa.io/en/stable/installation/ and download the latest version of pip.
Install npmο
Run the following command to check the installed npm version.npm --version
If you have not installed npm on your local machine, head over to https://nodejs.org/en/download/ and download the latest version of npm and Node.js.
Setting up the projectο
Head over to https://github.com/nearbeach/NearBeach and fork the repository to your own github account. You can skip this step if dont want to fork.Open a terminal, navigate to a folder where you want to setup this project
cd /path/to/your/project/folder
Download the project from the forked repository. Copy the link from the forked repository and run the following command in the terminal.
git clone <<Forked repo URL here>> cd ./NearBeachIf you have not forked the repository, you can clone the main repository using the following command
git clone https://github.com/nearbeach/NearBeach.git cd ./NearBeach
Download and install virtualenv
sudo pip3 install virtualenv
Create your own virtual environment for python
Note
you can use any name for the virtual environment, but it is recommended to use βvenvβ as it is already added to the .gitignore file
virtualenv venv
This will create a directory called βvenvβ in your current directory, this will store the required python libraries for the project
Activate the virtual environment
source ./venv/bin/activateYou terminal prompt will change to indicate that it is working in the virtual environment now. It should look like the following:
(venv)user@computer NearBeach$:
Install the python libraries
This will install all the required python libraries for the project
pip install -r requirements-dev.txt
Create the database
python3 manage.py migrate
Create a superuser for the application
Execute the following command and fill the user details when prompted.This user will act as super user for the NearBeach application. Use this user to login to the website once the Django app runs.python3 manage.py createsuperuser
Run the Django webserver
python3 manage.py runserverAlternatively, you can run the server on a different port using the following command
python3 manage.py runserver <<Port number>>Attention
If you see an error message like βDisallowedHost at /β, you need to add 127.0.0.1 to the allowed hosts in the
local/settings.py
file. Openlocal/settings.py
file and add127.0.0.1
to the ALLOWED_HOSTS listALLOWED_HOSTS = ['127.0.0.1']If all the above steps are followed correctly you should see the following output:
Performing system checks... System check identified no issues (0 silenced). October 27, 2024 - 12:00:00 Django version 3.2.8, using settings 'NearBeach.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.Note
Now that the server is running, you can access the NearBeach login page by visiting http://127.0.0.1:8000/loginYou can also access the Django admin page by visiting http://127.0.0.1:8000/admin
NPM/JavaScriptο
To install all NPM packages, please run the following code
npm install
Once npm has finished installing, compile the code using the following command
npm run prod
Alternatively, you can run a watch
npm run watch
Whats nextο
Now the road is clear for you to start contributing.
Head over to
local/NearBeach
folder. This is where all the python code is stored.Warning
DO NOT modifylocal/settings.py
!Before commiting the code please revert back the changes that are made tolocal/settings.py
file.See also
Hop on to our discord server - https://discord.gg/64uhRztS6n