From 50f89115efe79b2a93b54fed835d6a285f76510c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 25 Nov 2022 14:26:29 +0000 Subject: [PATCH] Add syntax highlighting to readme code snippets --- README.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6039a51..78fcdba 100644 --- a/README.md +++ b/README.md @@ -14,28 +14,36 @@ Tested against Django 2.2, 3.2 and 4.0 on Python 3.6, 3.7, 3.8, 3.9 and 3.10 Install from PIP - pip install django-simple-robots +```bash +pip install django-simple-robots +``` In your root urlconf, add an entry as follows: - from django.conf.urls import url - from simple_robots.views import serve_robots +```python +from django.conf.urls import url +from simple_robots.views import serve_robots - urlpatterns = [ - path("robots.txt", serve_robots), - # ..... other stuff - ] +urlpatterns = [ + path("robots.txt", serve_robots), + # ..... other stuff +] +``` Then, add `simple_robots` to `INSTALLED_APPS` in your `settings.py`. Optionally, set `ROBOTS_ALLOW_HOSTS` settings variable. - ROBOTS_ALLOW_HOSTS = ["myproductionurl.com"] +```python +ROBOTS_ALLOW_HOSTS = ["myproductionurl.com"] +``` `ROBOTS_ALLOW_HOSTS` also supports multiple options, similar to [`ALLOWED_HOSTS`](https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts): - # Allow all subdomains of `myproductionurl.com` (including the apex) and exactly `myotherproductionurl.com` (no subdomains) - ROBOTS_ALLOW_HOSTS = [".myproductionurl.com", "myotherproductionurl.com"] +```python +# Allow all subdomains of `myproductionurl.com` (including the apex) and exactly `myotherproductionurl.com` (no subdomains) +ROBOTS_ALLOW_HOSTS = [".myproductionurl.com", "myotherproductionurl.com"] +``` That's it!