WIP: generate title for non-content pages randomly from acronym table #4
3 changed files with 18 additions and 1 deletions
|
@ -78,6 +78,7 @@ TEMPLATES = [
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
'django.template.context_processors.media',
|
'django.template.context_processors.media',
|
||||||
|
'content.context_processors.random_title',
|
||||||
],
|
],
|
||||||
'loaders': [
|
'loaders': [
|
||||||
'django.template.loaders.filesystem.Loader',
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
|
16
content/context_processors.py
Normal file
16
content/context_processors.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from .models import Acronym
|
||||||
|
import random
|
||||||
|
|
||||||
|
def random_title(request):
|
||||||
|
count = Acronym.objects.count()
|
||||||
|
random_c = random.randint(1, count)
|
||||||
|
random_a = random.randint(1, count)
|
||||||
|
random_m = random.randint(1, count)
|
||||||
|
random_p = random.randint(1, count)
|
||||||
|
c = Acronym.objects.all()[random_c].c
|
||||||
|
a = Acronym.objects.all()[random_a].a
|
||||||
|
m = Acronym.objects.all()[random_m].m
|
||||||
|
p = Acronym.objects.all()[random_p].p
|
||||||
|
return {
|
||||||
|
'RANDOM_TITLE': f"{c} {a} {m} {p}"
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<title>CAMP</title>
|
<title>CAMP: {{ RANDOM_TITLE }}</title>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
|
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}?20250201">
|
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}?20250201">
|
||||||
|
|
Loading…
Add table
Reference in a new issue