1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# `pydis_site` project directory
This directory hosts the root of our **Django project**[^1], and is responsible
for all logic powering our website. Let's go over the directories in detail:
- [`apps`](./apps) contains our **Django apps**, which are the building blocks
that make up our Django project. A Django project must always consist of one
or more apps, and these apps can be made completely modular and reusable
across any Django project. In our project, each app controls a distinct part
of our website, such as the API or our resources system.
For more information on reusable apps, see the official Django tutorial,
[which has a section on reusable
apps](https://docs.djangoproject.com/en/dev/intro/reusable-apps/). To learn
more about our specific apps, see the README inside the app folder itself.
- [`static`](./static) contains our **static files**, such as CSS, JavaScript,
images, and anything else that isn't either content or Python code.
- [`templates`](./templates) contains our **[Django
templates](https://docs.djangoproject.com/en/dev/topics/templates/)**. Like
with static files, templates specific to a single application are stored in a
subdirectory named after that application. We also have two special templates
here:
- `404.html`, which is our error page shown when a site was not found.
- `500.html`, which is our error page shown in the astronomically rare case
that we encounter an internal server error.
Note that for both `static` and `templates`, we are not using the default Django
directory structure which puts these directories in a directory per app (in our
case, this would for example be ``pydis_site/apps/content/static/``).
We also have a few files in here that are relevant or useful in large parts of
the website:
- [`context_processors.py`](./context_processors.py), which contains custom
*context processors* that add variables to the Django template context. To
read more, see the [`RequestContext` documentation from
Django](https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.RequestContext)
- [`settings.py`](./settings.py), our Django settings file. This controls all
manner of crucial things, for instance, we use it to configure logging, our
connection to the database, which applications are run by the project, which
middleware we are using, and variables for `django-simple-bulma` (which
determines frontend colours & extensions for our pages).
- [`urls.py`](./urls.py), the URL configuration for the project itself. Here we
can forward certain URL paths to our different apps, which have their own
`urls.py` files to configure where their subpaths will lead. These files
determine _which URLs will lead to which Django views_.
- [`wsgi.py`](./wsgi.py), which serves as an adapter for
[`gunicorn`](https://github.com/benoitc/gunicorn),
[`uwsgi`](https://github.com/unbit/uwsgi), or other application servers to run
our application in production. Unless you want to test an interaction between
our application and those servers, you probably won't need to touch this.
For more information about contributing to our projects, please see our
[Contributing
page](https://www.pythondiscord.com/pages/guides/pydis-guides/contributing/).
[^1]: See [Django Glossary: project](https://docs.djangoproject.com/en/dev/glossary/#term-project)
|