2.
Random Quote Generator
Description: Display a random motivational quote each time the page is refreshed.
Key Concepts:
• URL routing
• Views
• Templates
• Python's random module
View Example:
import random
def random_quote(request):
quotes = [
"The best is yet to come.",
"Believe you can and you're halfway there.",
"Act as if what you do makes a difference. It does.",
"Success is not the key to happiness. Happiness is
the key to success."
]
quote = [Link](quotes)
return render(request, 'timeapp/random_quote.html',
{'quote': quote})
<div class="container text-center mt-5">
<h1 class="display-4">Random Quote</h1>
<p class="lead">{{ quote }}</p>
</div>