Fandjango的神秘问题

Fandjango的神秘问题

本文介绍了Fandjango的神秘问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用简单的django应用程序配置了fandjango.

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

以下是文件:

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.

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.

但是(这是BIG的问题)有时我会看到我的所有信息(如果条件为真),但是有时我看不到我的信息,而我会看到这里有问题".在数据库中,数据正常.

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.

推荐答案

而不是
{%,如果facebook_user.first_name%}
检查
{%,如果facebook.user%}

实际上,这将检查用户是否被授权;第一个可能会给您带来随机错误-也许在某些用户上缺少名字-.

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-.

这篇关于Fandjango的神秘问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 04:40