BJ_GOST
BJ_GOST

Reputation: 31

manage.py cant find any urls in myapp.urls file. Says something about circular import

I seem to find the following error despite making a number of changes in my app.urls file and in my project.urls file. I can't seem to put my finger on it, here is the code:

app.urls file

from django.urls import path
from . import views

urlpatterns = [
    path('', views.home_page, name = 'home_page'),

]

project.urls file

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('Success.urls')),
]

views.py file

from django.shortcuts import render from django.http import HttpResponse

enter code here

Create your views here.

def home_page(request):
  hello = 'hello world'
  return HttpResponse (hello)

Upvotes: 1

Views: 508

Answers (2)

BJ_GOST
BJ_GOST

Reputation: 31

i imported render and used it instead i can't figure out though why it worked

views.py file from django.shortcuts import render def hello_world(request): return render(request, 'hello_world.html')

app/urls.py from django.urls import path from . import views

    urlpatterns = [
      path('', views.hello_world, name = 'hello_world')
    ]

project/urls.py

    from django.contribs import admin
    from django.urls import path, include
    urlpatterns = [
      path('admin/', admin.site.urls),
      path('', include('app.urls'))
    ]
    

Upvotes: 0

dev740
dev740

Reputation: 121

Have you added your app in the settings.py file?

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'Success',
]

Upvotes: 0

Related Questions