Titivillus/user/views.py

30 lines
666 B
Python
Raw Normal View History

2018-09-05 14:45:43 -04:00
#!/usr/bin/env python3
"""
/user app views.
"""
from django.http import HttpResponse
from django.shortcuts import redirect, render
from django.core.exceptions import ObjectDoesNotExist
2018-08-10 18:55:20 -04:00
2018-09-05 14:45:43 -04:00
from .models import User
from quest.models import Quest
def index(request):
"""
The user index page.
"""
return HttpResponse("Hello, world. You're at the user index.")
def profile(request, user_id):
"""
User profile.
"""
try:
user = User.objects.get(id=user_id)
except ObjectDoesNotExist:
return HttpResponse(f"User_id {user_id} does not exist.")
quests = Quest.objects.filter(owner=user)
context = locals()
return render(request, 'user/profile.html', context)