django - 将 pyrebase 与 Django 一起使用时出现错误配置错误
问题描述
我试图pyrebase
在我的views.py中导入,但出现了一个错误:线程django-main-thread中的异常:
Traceback (most recent call last):
File "C:\Users\USER\Documents\python projects\yerekshe\lib\site-packages\django\urls\resolvers.py", line 581, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 'yerekshe.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
这是我的views.py:
from django.shortcuts import render, redirect
from .forms import UserForm, UserProfileInfoForm, UpdateProfileForm
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponseRedirect, HttpResponse
from django.urls import reverse
from . import forms
import pyrebase
config = {
'apiKey': "0",
'authDomain': "yerekshe.firebaseapp.com",
'databaseURL': "https://yerekshe.firebaseio.com",
'projectId': "yerekshe",
'storageBucket': "",
'messagingSenderId': "0",
}
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
def home(request):
return render(request, 'home.html')
def signIn(request):
return render(request, 'login.html')
def postsign(request):
email = request.POST.get('email')
passw = request.POST.get("pass")
try:
user = auth.sign_in_with_email_and_password(email, passw)
except:
message = "invalid cerediantials"
return render(request, "login.html", {"msg": message})
print(user)
return render(request, "home.html", {"e": email})
这里是 yerekshe\urls.py:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('account/', include('account.urls'))
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
解决方案
推荐阅读
- android - 在 Android 聊天应用中使用现有网站进行身份验证
- javascript - 单击 aria-expanded="false" 不会更改,并且“显示”类也不会添加到引导下拉菜单中 Angular 5
- arrays - 需要更有效的方式来读取子数组
- sonarqube - 排除特定规则 SonarQube
- c# - 在winforms中放置一个Listview的标签顶部中心
- sql-server - SQL - # 创建临时表时使用
- javascript - void(args) 在 javascript 中做了什么?
- r - 将混合字符串拆分为R中的列
- c++ - 存储迭代器的 iterator_category 应该是什么?
- ruby-on-rails - 实例对象被自动覆盖