36449-vm/core/views.py
Flatlogic Bot f1c5cc6862 version1
2025-11-28 22:13:49 +00:00

32 lines
1.5 KiB
Python

from django.shortcuts import render
from .models import Story
def index(request):
# Create sample stories if they don't exist
if not Story.objects.exists():
stories_data = [
{
'title': 'Feeling Overwhelmed',
'content': 'Lately, I\'ve been feeling really overwhelmed with work and personal life. It feels like I\'m constantly juggling a million things and I\'m afraid I\'m going to drop the ball on something important.',
'author_name': 'Anxious Panda',
'author_avatar': '🐼'
},
{
'title': 'Struggling to find motivation',
'content': 'I used to be so passionate about my hobbies, but now I can\'t seem to find the motivation to do anything. I just feel kind of empty and I don\'t know how to get that spark back.',
'author_name': 'Lazy Lion',
'author_avatar': '🦁'
},
{
'title': 'Dealing with a difficult friendship',
'content': 'I have a friend who is constantly negative and it\'s starting to bring me down. I want to be there for them, but I also need to protect my own mental health. How do I find that balance?',
'author_name': 'Confused Cat',
'author_avatar': '🐱'
}
]
for story_data in stories_data:
Story.objects.create(**story_data)
stories = Story.objects.all().order_by('-created_at')
return render(request, 'core/index.html', {'stories': stories})