Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2c7c1b3
Switch to mkdocs material theme
browniebroke Dec 9, 2025
319dbcd
Add logo
browniebroke Dec 12, 2025
e277940
Style badges on homepage
browniebroke Dec 12, 2025
68203cb
Basic dark theme
browniebroke Dec 12, 2025
a8af6a7
Enable a few theme features
browniebroke Dec 13, 2025
0b98599
Customise large logo for dark theme
browniebroke Dec 13, 2025
cd2ee60
CSS tweaks
browniebroke Dec 13, 2025
fbe8731
Add background grid back
browniebroke Dec 13, 2025
3f5399b
Switch to mkdocs material theme
browniebroke Dec 9, 2025
38f5513
Add logo
browniebroke Dec 12, 2025
6d5dd9c
Style badges on homepage
browniebroke Dec 12, 2025
5a44bec
Basic dark theme
browniebroke Dec 12, 2025
2ea8cb1
Add syntax highlighting to code snippets
browniebroke Dec 15, 2025
05cabcd
Merge remote-tracking branch 'origin/feat/mkdocs-material' into feat/…
browniebroke Dec 15, 2025
9125483
Convert homepage snippets to code fences
browniebroke Dec 15, 2025
2087222
Update homepage logos
browniebroke Dec 15, 2025
4efe942
Merge branch 'main' into feat/mkdocs-material
browniebroke Feb 10, 2026
3091af7
Move mkdocs-material to pyproject.toml docs group
browniebroke Feb 10, 2026
35be8fb
Keep existing syntax highlighting
browniebroke Feb 10, 2026
692196a
Remove old docs_theme folder
browniebroke Feb 10, 2026
4b6053b
Tweak syntax highlighting colors on dark theme
browniebroke Feb 10, 2026
abc1951
Add readthedocs config file
browniebroke Feb 11, 2026
fc2ca65
Fix end of file empty lines
browniebroke Feb 11, 2026
339a04f
Upgrade pip during install
browniebroke Feb 11, 2026
2563b83
Merge branch 'main' into feat/mkdocs-material
browniebroke Feb 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
*.pyc
*.db
*~
.*
*.py.bak


Expand All @@ -14,6 +13,8 @@
/env/
MANIFEST
coverage.*
.coverage
.cache/

!.github
!.gitignore
Expand Down
19 changes: 19 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version, and other tools you might need
build:
os: ubuntu-24.04
tools:
python: "3.13"
jobs:
install:
- pip install --upgrade pip
- pip install -e . --group docs

# Build documentation with Mkdocs
mkdocs:
configuration: mkdocs.yml
Binary file added docs/img/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/logo-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/img/logo.png
Binary file not shown.
112 changes: 63 additions & 49 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
</style>

<p class="badges" height=20px>
<div class="badges">
<iframe src="https://ghbtns.com/github-btn.html?user=encode&amp;repo=django-rest-framework&amp;type=watch&amp;count=true" class="github-star-button" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>

<a href="https://github.com/encode/django-rest-framework/actions/workflows/main.yml">
Expand All @@ -27,11 +27,10 @@
<a href="https://pypi.org/project/djangorestframework/">
<img src="https://img.shields.io/pypi/v/djangorestframework.svg" class="status-badge">
</a>
</p>
</div>

---

<p>
<h1 style="position: absolute;
width: 1px;
height: 1px;
Expand All @@ -41,8 +40,8 @@
clip: rect(0,0,0,0);
border: 0;">Django REST Framework</h1>

<img alt="Django REST Framework" title="Logo by Jake 'Sid' Smith" src="img/logo.png" width="600px" style="display: block; margin: 0 auto 0 auto">
</p>
![Django REST Framework](img/logo-light.png#only-light)
![Django REST Framework](img/logo-dark.png#only-dark)

Django REST framework is a powerful and flexible toolkit for building Web APIs.

Expand Down Expand Up @@ -79,27 +78,35 @@ The following packages are optional:

Install using `pip`, including any optional packages you want...

pip install djangorestframework
pip install markdown # Markdown support for the browsable API.
pip install django-filter # Filtering support
```bash
pip install djangorestframework
pip install markdown # Markdown support for the browsable API.
pip install django-filter # Filtering support
```

...or clone the project from github.

git clone https://github.com/encode/django-rest-framework
```bash
git clone https://github.com/encode/django-rest-framework
```

Add `'rest_framework'` to your `INSTALLED_APPS` setting.

INSTALLED_APPS = [
...
'rest_framework',
]
```python
INSTALLED_APPS = [
# ...
"rest_framework",
]
```

If you're intending to use the browsable API you'll probably also want to add REST framework's login and logout views. Add the following to your root `urls.py` file.

urlpatterns = [
...
path('api-auth/', include('rest_framework.urls'))
]
```python
urlpatterns = [
# ...
path("api-auth/", include("rest_framework.urls"))
]
```

Note that the URL path can be whatever you want.

Expand All @@ -111,44 +118,51 @@ We'll create a read-write API for accessing information on the users of our proj

Any global settings for a REST framework API are kept in a single configuration dictionary named `REST_FRAMEWORK`. Start off by adding the following to your `settings.py` module:

REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
]
}
```python
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"
]
}
```

Don't forget to make sure you've also added `rest_framework` to your `INSTALLED_APPS`.

We're ready to create our API now.
Here's our project's root `urls.py` module:

from django.urls import path, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets

# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ['url', 'username', 'email', 'is_staff']

# ViewSets define the view behavior.
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer

# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter()
router.register(r'users', UserViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
path('', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]
```python
from django.urls import path, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets


# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ["url", "username", "email", "is_staff"]


# ViewSets define the view behavior.
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer


# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter()
router.register(r"users", UserViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
path("", include(router.urls)),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
]
```

You can now open the API in your browser at [http://127.0.0.1:8000/](http://127.0.0.1:8000/), and view your new 'users' API. If you use the login control in the top right corner you'll also be able to add, create and delete users from the system.

Expand Down
File renamed without changes.
File renamed without changes
Binary file added docs/theme/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
13 changes: 13 additions & 0 deletions docs/theme/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "base.html" %}

{% block scripts %}
{{ super() }}
<script>
document$.subscribe(function() {
document.querySelectorAll('pre code').forEach(code => {
code.parentElement.classList.add('prettyprint', 'well');
});
prettyPrint();
});
</script>
{% endblock %}
81 changes: 81 additions & 0 deletions docs/theme/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
:root > * {
/* primary */
--md-primary-fg-color: #2c2c2c;
--md-primary-fg-color--light: #a8a8a8;
--md-primary-fg-color--dark: #181818;
/* accent */
--md-accent-fg-color: #c50d0d;
--md-accent-fg-color--light: #ff8f8f;
--md-accent-fg-color--dark: #A30000;

/* Style links */
--md-typeset-a-color: var(--md-typeset-color);
}

/* Dark theme customisation */
[data-md-color-scheme="slate"]
{}

.md-header {
border-top: 5px solid var(--md-accent-fg-color--dark);
}

body hr {
border-top: 1px dotted var(--md-accent-fg-color--dark);
}

.badges {
display: flex;
flex-direction: row-reverse;
align-content: end;
gap: 8px;
}

/* Cutesy quote styling */
[dir="ltr"] .md-typeset blockquote {
font-family: Georgia, serif;
font-size: 18px;
font-style: italic;
margin: 0.25em 0;
padding: 0.25em 40px;
line-height: 1.45;
position: relative;
color: var(--md-typeset-color);
border-left: none;
}

[dir="ltr"] .md-typeset blockquote:before {
display: block;
content: "\201C";
font-size: 80px;
position: absolute;
left: -10px;
top: -20px;
color: #7a7a7a;
}

[dir="ltr"] .md-typeset blockquote p:last-child {
color: #999999;
font-size: 14px;
display: block;
margin-top: 5px;
}

.md-typeset a {
color: var(--md-accent-fg-color--dark);
}

/* Replacement for `body { background-attachment: fixed; }`, which
has performance issues when scrolling on large displays. */
body::before {
content: ' ';
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #f8f8f8;
background: url(../img/grid.png) repeat-x;
will-change: transform;
z-index: -1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
.typ, .atn, .dec, .var { color: teal; }
.pln { color: #48484c; }

[data-md-color-scheme="slate"]
{
.com { color: #687272; }
.lit { color: #2481c7; }
.str, .atv { color: #e02642; }
.kwd, .prettyprint .tag { color: #5b7acb; }
.typ, .atn, .dec, .var { color: #05abab; }
.pln { color: #d3d3dc; }
}

.prettyprint {
padding: 8px;
background-color: #f7f7f9;
Expand Down
9 changes: 0 additions & 9 deletions docs_theme/404.html

This file was deleted.

Loading