2016-11-27 61 views
0

我正在使用django-rest-auth作爲與android作爲前端的facebook集成。我遵循了集成django-rest-auth中提到的所有步驟。「django-rest-auth」DoesNotExist:不存在網站匹配查詢

我只有一個網站,並設置SITE_ID 1

我還設置客戶端ID和我的應用程序的祕密ID,並確保我已經選擇我的網站。

下面是截圖

​​

下面是我的代碼

INSTALLED_APPS = [ 
    'rest_auth', 
    'django.contrib.sites', 
    'allauth', 
    'allauth.account', 
    'allauth.socialaccount', 
    'allauth.socialaccount.providers.facebook', 
] 

我的自定義登錄串行

REST_AUTH_SERIALIZERS = { 
    'LOGIN_SERIALIZER': 'cut_veggie_user.serializers.NormalUserSerializer', 
} 

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend', 
    'allauth.account.auth_backends.AuthenticationBackend', 
) 

SITE_ID = 1 

在網址我也包括了FacebookLogin

urlpatterns = [ 
       url(r'^rest-auth/facebook/$', FacebookLogin.as_view(),  name='fb_login'), 
      ] 

有誰能告訴我我錯過了什麼嗎?

+0

請描述錯誤或發出您正在運行到 – Dap

+0

這是錯誤我得到的,DoesNotExist:網站匹配的查詢不存在 –

回答

0

最終找出問題所在。

我也跟着下面的步驟

蟒蛇manage.py殼

然後我通過這個命令

from django.contrib.sites.models import Site 
new_site = Site.objects.create(domain='foo.com', name='foo.com') 
print new_site.id 

得到了我的網站,該網站的ID,並添加id來SITE_ID在settings.py

令我驚訝的是,我得到了網站ID爲3,W我不知道爲什麼。

由於this