我正在工作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, )
这是一个项目结构