This tutorial covers the get_profile() and the @login_required decorator
# URL for @login_required decorator to use LOGIN_URL = '/login/' # redirect authenticated users LOGIN_REDIRECT_URL = '/profile/'
@login_required def Profile(request): if not request.user.is_authenticated(): return HrttpResponseRedirect('/login/') drinker = request.user.get_profile context = {'drinker': drinker} return render_to_response('profile.html', context, context_instance=RequestContext(request))
{% extends "base.html" %} {% block content %} <p>Name: {{ drinker.name }}</p> <p>Birthday: {{ drinker.birthday }}</p> {% endblock %}
(r'^profile/$', 'drinker.views.Profile'),