Click to expand
- Install uv (a Python package manager)
- Install Git
- Installing a Git GUI is highly recommended, as they allow for much easier and faster visualization of
the commit structure, and interaction with it, which will help you avoid many common mistakes
- Git Extensions is an excellent choice, with support for pretty much all Git features you'll ever use - though it only runs on Windows, as of time of writing
- GitHub Desktop works well, but has very limited functionality
- Clone this repository to your machine
- Either press a "Clone repository" button in your Git GUI, or run:
git clone https://github.com/MAKENTNU/web.git
- Either press a "Clone repository" button in your Git GUI, or run:
- Install dev dependencies:
(this will create a
.venvfolder inside your repository folder, by default)uv sync --group dev
- Create an empty
.envfile directly inside the repository folder, and fill it by copying the contents of.env.example - To be able to run commands in the
Makefile:- If using Windows:
- Ensure that you have a program installed that can run makefiles.
This can be done by e.g. installing
GnuWin's Make using
WinGet:
winget install GnuWin32.Make
- Ensure that you have a program installed that can run makefiles.
This can be done by e.g. installing
GnuWin's Make using
WinGet:
- If using Linux/macOS: You don't need to do anything.
- If using Windows:
We recommend using PyCharm for development, mostly because of its excellent Django support,
and because it's able to integrate all the IntelliJ-specific settings in the project's .editorconfig file.
If you decide to use this IDE, open the repo folder cloned as part of the prerequisites, through PyCharm (File → Open...), and set the following settings (File → Settings...):
- Under "Python" → "Django":
- Make sure the "Enable Django Support" checkbox is checked
- "Django project root:"
<repo folder location>/src - "Settings:"
web/settings.py - "Manage script:"
<repo folder location>/manage.py
- Under "Project Structure":
- Mark the
srcfolder as "Sources"
- Mark the
- Follow these instructions
to add the existing uv environment that you created inside the
.venvfolder
We recommend developing using locally installed dependencies, as it's a lot faster and easier to debug, but if you'd like to use Docker (e.g. for testing stuff in a prod-like environment), follow the instructions under the "Using Docker" section instead.
- Create an SQLite database file with the proper tables:
uv run manage.py migrate
- Create an admin user for local development:
It's easiest to create one with both the username and the password set to "admin", and with no email address.
uv run manage.py createsuperuser
- Run the server:
- If using PyCharm, just press the green "play" button in the top right corner
- Make sure that the correct run configuration is selected in the dropdown next to the button, which by default should be named "web" and have a tiny Django logo
- Otherwise, run:
uv run manage.py runserver
- If using PyCharm, just press the green "play" button in the top right corner
-
Create a
.env.dockerfile:This will contain environment variables that override the ones in
.env, which will be used by code running inside Docker.The following file contents is a good basis:
STATIC_AND_MEDIA_FILES__PARENT_DIR='/vol/web/'
-
Build the Docker image and create the database:
make d-update
-
Create an admin user for local development:
make d-createsuperuser
-
Run the server:
- If using PyCharm:
- Add a Docker-based Python interpreter
with
make_ntnuas project name (this should match the-pargument in theMakefile) - Create a "Django Server" run configuration using the newly created
Python interpreter, with
0.0.0.0(instead oflocalhost) as host (this should match the IP address specified by thecommandkey incompose.dev.yaml) - Press the green "play" button in the top right corner
- Add a Docker-based Python interpreter
with
- Otherwise, run:
make d-start
- If using PyCharm:
If you encounter any hard-to-fix Docker-related problems, an easy (but drastic) fix can sometimes be to delete the container (make d-down)
and follow the steps above again.
When running uv commands, pass the --offline flag.
For example:
uv run --offline manage.py runserver
# Using the make command:
make start uv_args="--offline"See CONTRIBUTING.md for the following topics:
📖 Wiki
Visit the wiki to read about various things related to development of this project!
View the changelog to see a list of changes made to the website over time, as well as a high-level description of the release process.