Mysterious problem with Fandjango

懵懂的女人 提交于 2019-12-11 03:33:14

问题


I've just configured fandjango with my simply django application.

Here's the files:

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 %}

Now, when I go to http://apps.facebook.org/myapplicationname and I allow the access for application to take account's infos, I see the home.html.

BUT (here's the BIG problem) sometimes I see all my infos (if condition is true) but sometimes I don't see my info and I see "There's a problem here". In the database the data is ok.

I've checked this with others account and there's still this mysterious problem.


回答1:


Instead of doing
{% if facebook_user.first_name %}
check for
{% if facebook.user %}

That will actually check for the user if he was authorized; the first one may give you random errors -missing first name on some users maybe-.




回答2:


Do you have caching turned on in your application? Does the problem occur more or less when you do a full refresh?

Is facebook limiting your calls to the authentication API?

Does fandjango properly cache those? Does your problem show up most often if you refresh the page a bunch of times, but goes away if you leave it alone for a while and come back?

Are you actually running the latest version of fandjango?



来源:https://stackoverflow.com/questions/6433391/mysterious-problem-with-fandjango

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!