2011-06-21 41 views
2

我剛剛配置了我的簡單django應用程序fandjango。Fandjango的神祕問題

這裏的文件:

VIEWS.PY

from django.http import HttpResponse 
from django.shortcuts import render 
from fandjango.decorators import facebook_authorization_required 

@facebook_authorization_required() 
def home(request): 
    return render(request, 'home.html', {'facebook_user': request.facebook.user}) 

home.html的

{% if facebook_user.first_name %} 
You are:<br> 

{{ facebook_user.first_name }} {{ facebook_user.last_name }}. 
<br>ID: {{ facebook_user.facebook_id }} 
<br>YOUR URL: {{ facebook_user.profile_url }} 
<br><img src="http://graph.facebook.com/{{ facebook_user.facebook_id }}/picture?type=large"> 

{% else %}There's a problem here.{% endif %} 

現在,當我去http://apps.facebook.org/myapplicationname,我允許應用程序的訪問考慮到帳戶的信息,我看到了home.html。

但是(這裏是BIG問題)有時我會看到我的所有信息(如果條件爲真),但有時我沒有看到我的信息,而我看到「這裏有問題」。在數據庫中數據是可以的。

我已經檢查了這個與他人帳戶,仍然存在這個神祕的問題。

回答

1

而不是做
{%如果facebook_user.first_name%}
檢查
的{%如果facebook.user%}

這實際上會檢查用戶,如果他被授權;第一個可能會給你隨機的錯誤 - 可能會在某些用戶中忽略名字。

0

您的應用程序中是否打開了緩存?當您進行全面更新時,問題會多多少少出現?

Facebook是否限制您對認證API的調用?

fandjango是否正確地緩存這些內容?如果您多次刷新頁面,您的問題會最常出現,但如果您將它放置一段時間並返回,您的問題會消失嗎?

你真的在運行最新版本的fandjango嗎?