28 lines
626 B
Python
Executable File
28 lines
626 B
Python
Executable File
from django.shortcuts import render
|
|
from django.shortcuts import get_object_or_404
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.conf import settings
|
|
|
|
def general_ctx(request):
|
|
ctx = {
|
|
'login_url': settings.LOGIN_URL,
|
|
'logout_url': '/accounts/logout/',
|
|
'user': request.user,
|
|
}
|
|
|
|
return ctx
|
|
|
|
# Create your views here.
|
|
def profile(request, username):
|
|
User = get_user_model()
|
|
user = get_object_or_404(User, username=username)
|
|
photos = user.photo_set.order_by('-pk').all()
|
|
|
|
ctx = general_ctx(request)
|
|
ctx['user'] = user
|
|
ctx['photos'] = photos
|
|
|
|
print(ctx)
|
|
|
|
return render(request, 'profile.html', ctx) |