CodePlay is a competitive coding website with gamification elements for university students. Personal contribution:
- Developed the "practice" feature which includes giving the users random programming problems, testing their solutions, and giving them rewards based on their performance.
- Implemented such accessibility features as font size change and optional dyslexia font.
- Configured the Django project for the team and prepared the setup instructions for development.
Using Python >3.10.4 features may break things.
- pip v24.0 (may already be installed by default, but if you don't have it, here's how to get it)
- Django v5.0.1
- SQLite (comes together with Python)
- asgiref v3.7.2
- sqlparse v0.4.2
- WhiteNoise v6.6.0
- daphne v4.1.0
- channels v4.0.0
There's no need to install anything but Python and pip manually. All the remaining dependencies will be installed straight into your virtual environment (read the section below).
- Create a folder called
venvin the root directory of the cloned repository. - Navigate to the
venvfolder in the terminal. - Run
py -3.10 -m venv .. This should create the virtual environment files invenv. - Activate the virtual environment using
./Scripts/activate - Run
pip install -r requirements.txtto install the dependencies. - You can deactivate the virtual environment by running
deactivate.
Make sure your virtual environment is always on when you're developing.
Note: application != an entire project. One project (i.e. website) can (and, ideally, should) have multiple applications (e.g. authentication system, blog, dashboard, etc.). To ensure best development experience, create a new application for each feature.
- Run
django-admin startproject codeplayin repo base directory to generate the foundation:
codeplay/ - root directory for the whole project
codeplay/ - actual Python package for the project
__init__.py - empty file that indicates this directory is a Python package
asgi.py - entry point for ASGI web servers
settings.py - project settings/config file
urls.py - project URL declarations
wsgi.py - entry point for WSGI web servers
manage.py - command-line utility
- Run
python manage.py runserverin the project root directory to start a local dev server on port 8000 - Run
python manage.py startapp appnamein root directory to generate the application structure:
appname/
__init__.py
admin.py
apps.py
migrations/
__init__.py
models.py
tests.py
views.py
- Create
urls.pyin the application directory for handing URLs.
- Run
pip install -r requirements.txtto install dependencies via pip. - Run
python manage.py migrateto create any necessary DB tables for settings.INSTALLED_APPS. - Run
python manage.py makemigrations appnameto create DB tables for each app. - Run
python manage.py createsuperuserto create an admin user. - Run
python manage.py collectstaticto dump all the static files into their special directory (required for static files to work in deployment). - Run
python manage.py check --deployto check if your project is ready for deployment. - Run
$env:DJANGO_SETTINGS_MODULE="codeplay.settings.localdev"in the VS Code terminal while in the base directory to switch to development settings. - Run
$env:DJANGO_SETTINGS_MODULE="codeplay.settings.deploy"in the VS Code terminal while in the base directory to switch to production settings.
- Only commits made to the
prod-branchbranch are pushed to prod. - Your commits to the main branch will only be visible in the dev environment (not prod).
- The commits don't have to be tagged anymore.