I am trying to create an webpage using Python and Django. I have just created a simple template and tried to run the sever but I get errors and I'm not able to understand..
I check all the spelling in my projects and searched the similar issues, however I am not able to solve it.
settings.py
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# My apps
'learning_logs',
]
urls.py
from django.urls import path, include
from django.contrib import admin
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('learning_logs.urls')),
]
views.py
from django.shortcuts import render
# Create your views here.
def index(request):
"""The home page for Learning Log"""
return render(request, 'learning_logs/index.html')
urls.py // This is second URL
"""Defines url patterns for learning_logs."""
from django.urls import path
from . import views
app_name = 'learning_logs'
urlpatterns = [
# Home page.
path('', views.index, name='index'),
]
Error on command prompt when I tried to run server:
"C:\Users\User\Desktop\python_work\project_3\learning_log\11_env\lib\site-packages\django\urls\resolvers.py", line 535, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable
During handling of the above exception, another exception occurred:
.....
"C:\Users\User\Desktop\python_work\project_3\learning_log\11_env\lib\site-packages\django\urls\resolvers.py", line 542, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'learning_logs.urls' (namespace)>'
does not appear to have any patterns in it.
If you see valid patterns in the file then the issue is probably caused by a circular import.