由于我将Django应用程序部署到heroku,因此在打开项目时遇到错误。它在本地环境中工作得很好,但是在推送到django后出现以下错误:
ImportError at /
cannot import name 'login'
Request Method: GET
Request URL: https://blooming-headland-56472.herokuapp.com/
Django Version: 2.1
Exception Type: ImportError
Exception Value:
cannot import name 'login'
Exception Location: /app/Clientes/urls.py in <module>, line 5
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.6.6
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python36.zip',
'/app/.heroku/python/lib/python3.6',
'/app/.heroku/python/lib/python3.6/lib-dynload',
'/app/.heroku/python/lib/python3.6/site-packages']
Server time: Sex, 24 Ago 2018 11:32:30 +0000
我的urls.py看起来像这样:
from django.urls import path
from . import views
from django.conf import settings
from django.contrib.auth import views as auth_views
from django.contrib.auth.views import (
login, logout, password_reset, password_reset_done,
password_reset_confirm
)
from django.conf.urls.static import static
app_name = 'client'
urlpatterns = [
path('register/', views.register, name='register'),
path('login/', login, {'template_name': 'Clientes/login.html'},
name='login'),
path('mail/', views.mail, name='mail'),
path('profile/config', views.config_view, name="config"),
path('profile/dashboard', views.dashboard_view, name="dashboard"),
path('reset-password/', password_reset, name="reset_password"),
path('reset-password/done/', password_reset_done,
name="password_reset_done"),
path('reset-password/confirm/', password_reset_confirm,
name="password_reset_confirm"),
path('profile/logout/', views.logout_view, name='logout'),
path('profile/', views.ProfileView.as_view(), name='profile'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)