django - 如何跟踪循环导入错误 Django 从未解决
问题描述
我正在工作 Django rest framework api 项目,我在项目中有多个应用程序。将应用程序 URL 添加到主 URL 时出现循环导入错误。我尝试了所有检查拼写,检查应用程序结构但没有用的东西。问题真的很令人沮丧。请帮助解决问题。当我取消新添加的线路时,该应用程序运行良好path("covid/", include("Covid.urls")),
我正在使用 python3.6、django 3.0.4 和 django-rest-framework 3.11.0
这是项目 urls.py
from django.contrib import admin
from django.conf.urls import url
from django.urls import path, include
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='TmmrwInc API Documentation')
urlpatterns = [
path('admin/', admin.site.urls),
# path('', include('django.contrib.auth.urls')),
# path('rest_auth/', include('rest_auth.urls')),
path('api/password_reset/',
include('django_rest_passwordreset.urls', namespace='password_reset')),
# url(r'^invitations/', include('invitations.urls', namespace='invitations')),
path('', include('rest_invitations.urls')),
path("", include("UserAuth.urls")),
path("doctors/", include("Administration.urls")),
path("appointments/", include("Appointments.urls")),
path("messaging/", include("messaging.urls")),
path("meet/", include("meet.urls")),
path("api_documentation/", schema_view),
path("covid/", include("Covid.urls")),
]
这是应用程序urls.py文件
from django.urls import path
from . import views
app_name = 'Covid'
urlpatterns = [
path('event/', views.EventBookingView.as_view()),
]
settings.py安装的应用程序
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.sites",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"UserAuth",
"rest_framework",
"corsheaders",
'rest_framework.authtoken',
'rest_auth',
'Appointments',
'messaging',
'Administration',
'channels',
'invitations',
'rest_invitations',
'django_rest_passwordreset',
'django_celery_beat',
'meet',
'rest_framework_swagger',
'Covid',
]
这是我的应用程序views.py文件
from django.shortcuts import render
from rest_framework.generics import CreateAPIView, RetrieveAPIView, ListAPIView, UpdateAPIView
from rest_framework.permissions import IsAuthenticated, AllowAny
from rest_framework.response import Response
from rest_framework import status, viewsets
from .serializers import OfficeSearchSerializer, EventSerializer, SymptomSerializer, PatientSymptomSerializer
# Create your views here
class OfficeSearchView(ListAPIView):
serializer_class = OfficeSearchSerializer
permission_class = (AllowAny,)
lookup_field = 'pk'
class EventBookingView(CreateAPIView):
serializer_class = EventSerializer
permission_class = (AllowAny, )
这是一个项目结构
解决方案
推荐阅读
- pytest - 如何参数化我的夹具并获取测试数据来参数化我的测试
- python - 如何在 pandas 的组中删除某种类型的值?
- python - 使用元素的索引进行交换
- ios - 为什么 Picker 的 .onReceive 都会触发?
- javascript - req.flash 不是功能快递护照
- android - 添加 com.google.android.material 后,Android 底部导航栏颜色变为黑色
- neo4j - 通过 neo4j 密码中的过滤器处理参数化顺序
- javascript - 如何按角色数组过滤对象?
- python-3.x - 同时使用多个虚拟环境的可能性
- java - 通过进程识别打开的 FileOutputStreams