【发布时间】:2011-03-29 09:49:16
【问题描述】:
我似乎被困住了,不确定哪个是最好的方向。
我的项目中有几个应用程序,想将三个视图合并到一个模板中。
我有一个用户个人资料,我想在其中显示他的信息、最新新闻提要以及他的照片
通过这个,我正在使用 jQuery 选项卡
我已经定义了我的三个选项卡,其中一个调用常规 div,另外两个是调用的 url。
<a href="wall/recent">wall</a> 和 <a href="photos/recent">photos</a>
在用户个人资料上时,地址栏会显示以下内容
http://localhost:8000/profiles/profile_name/
在我的views.py 中,wall 和 photos 如下所示
@login_required
def index(request, template_name='wall/_index.html'):
photos = Photos.objects.filter(user=request.user).order_by('-id')
context = { 'photos': photos, }
return render_to_response(template_name, context,
context_instance=RequestContext(request))
但是,如果我再看一下我的个人资料,那就没问题了,但是每当我切换到其他用户的个人资料时,它似乎仍然会显示我的一些信息。
我知道 request.user 正在查看已登录的用户,我如何在地址栏中获取该用户并将其传递给它以显示正确的信息,即如果 profile_name = john 然后显示 johns 照片,最近墙壁物品等。
【问题讨论】:
标签: jquery django-templates django-views jquery-tabs