I'm Using
-
django in its version: 1.11.4
-
python 3.6 in linux debian
I have the following files configured in settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'home',
'about',
'contact',
]
urls.py is set up like this:
from django.conf.urls import url
from django.contrib import admin
from home import views
from about import views
from contact import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^home/$', views.Home, name='home'),
url(r'^about/$', views.About, name='about'),
url(r'^contact/$', views.Contact, name='contact'),
]
home / views.py with the following code
from django.shortcuts import render
from django.http import HttpResponse
def home(request):
return render(request, 'Home.html')
contact / views.py I wrote it that way
from django.shortcuts import render
from django.http import HttpResponse
from .models import Contact
def contact(request):
contacts = Contact.objects.all()
return render(request, 'Contact.html', {'contacts': contacts})
Finally I have the folder templates with its files:
- home.html,
- about.html,
- contact.html
When executing the command
python manage runserver
the console displays the following error:
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
url(r'^home/$', views.Home, name='home'),
AttributeError: module 'contact.views' has no attribute 'Home'
I have made different configurations, I can not find what the error is