ここで説明したように、このチュートリアルを実行しました:
そしてここ
しかし、私が理解できないいくつかの点があります。
Facebookアカウントを使用してログインすると、管理ページにも簡単にアクセスできますが、(安全ではないため)アクセスしたいのですが、それを修正する方法はありますか?
その登録済みユーザーを別のテンプレートに移動したい場合は、URL ディスパッチャーの direct_to_template メソッドでのみ実行できます。例を次に示します
url(r'^tags$', direct_to_template, {'template' : 'user.html' })
。
それを行う別の方法はありますか。
最後に、より明確にするために、ここに私のプロジェクトの一部を示します。
urls.py
urlpatterns = patterns('',
#All Auth URLS
url(r'^accounts/', include('allauth.urls')),
url(r'^accounts/profile/', direct_to_template, { 'template' : 'profile.html' }),
#nav urls
url(r'^$','fb.views.home', name="home"),
url(r'^tags$', direct_to_template, {'template' : 'tags.html' }),
ビュー.py
def home(request):
return render_to_response("base.html", locals(), RequestContext(Context))
base.html
.....
{% block body %}
{% block content %}
{% if user.is_authenticated %}
{{ user.username }} <p> you are logged in </p>
<p><a href="/accounts/logout/" >Logout </a></p>
{% else %}
<p> you are not authenticated : </p>
<a href="/accounts/facebook/login/" >Login with Facebook </a>
{% endif %}
{% endblock content %}
{% endblock body %}
...
profile.html
...
{% block content %}
{% if user %}
<h1>Welcome, {{user.first_name}}</h1>
<p>Following is the Extra information that facebook has provided to allauth:</p>
{% for account in user.socialaccount_set.all %}
<p>First Name: {{ account.extra_data.first_name }}</p>
<p>Last Name: {{ account.extra_data.last_name }}</p>
<p>Profile Link: <a href="{{ account.extra_data.link }}">{{ account.extra_data.link }}</a></p>
{% endfor %}
{% endif %}
<a href="/tags"> Go to tags</a>
{% endblock content %}
{% endblock body %}
tags.html
{{user.socialaccount_set.all.0.get_avatar_url}} <br/>
{{user.socialaccount_set.all.0.uid}} <br/>
{{user.socialaccount_set.all.0.get_provider_account }} <br/>
最後に、ご協力いただきありがとうございます。