On 22/07/2020 10:08 am, Sai wrote:
> I am working Django rest framework api project, where I had multiple
> apps in the project. I got a circular import error when I am adding
> the app URLs to the main URLs. I Tried everything checked spellings,
> checked app structure but no use. Its been really frustrating with
> issue..please help to solve the problem. The app is working fine when
> I take off newly added line `path("covid/", include("Covid.urls")),`

I can't help specifically but generally maybe. I have never been able to
trace circular imports. Instead I just remove them and drop them into
the methods which need them.

At first glance "from django.conf.urls import url" seems to be unused.
I'd try again without it or if I missed something you could add re_path
to the django.urls imports.

Hope I haven't steered you down a blind alley.

M


>
> I am using python3.6, django 3.0.4 and django-rest-framework 3.11.0
>
> Here is project 
> **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")),
>     ]
>
> This is app **urls.py** file
>
>     from django.urls import path
>     from . import views
>     
>     app_name = 'Covid'
>     
>     urlpatterns = [
>         path('event/', views.EventBookingView.as_view()),
>     ]
>
> **settings.py** installed apps 
>
>     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',
>     
>     ]
>
> This is a project structure
>
> [Project Structure][1]
>
>
>   [1]: https://i.stack.imgur.com/E8qro.jpg
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/90296ccf-c893-4cf1-b57a-2da47396a2bbo%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/90296ccf-c893-4cf1-b57a-2da47396a2bbo%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68400690-f3b1-305e-83b1-577767bc7469%40dewhirst.com.au.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to