generate title for non-content pages randomly from acronym table
This commit is contained in:
parent
1e408d9b25
commit
76d96e76fe
3 changed files with 18 additions and 1 deletions
|
@ -78,6 +78,7 @@ TEMPLATES = [
|
|||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.template.context_processors.media',
|
||||
'content.context_processors.random_title',
|
||||
],
|
||||
'loaders': [
|
||||
'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 name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
{% block head %}
|
||||
<title>CAMP</title>
|
||||
<title>CAMP: {{ RANDOM_TITLE }}</title>
|
||||
{% endblock %}
|
||||
<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">
|
||||
|
|
Loading…
Add table
Reference in a new issue