Justin
Justin

Reputation: 1

ModuleNotFoundError: No module named 'HomePage'

I cannot figure out why I keep getting the ModuleNotFoundError: No module named 'HomePage' error I'm fairly new to Django but have spent a majority of the day trying to figure out how to make a homepage where I could link a Homepage.html and have a different page on my original page. Any help would be appreciated this is my second question ever on here please be gentle.

This is inside my mysite/urls.py

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('music.urls')),
    url(r'^blog/', include('blog.urls')),
    url(r'^HomePage/',include('HomePage.urls')),
]

This is my installed apps in settings.py in the mysite directory. # Application definition

INSTALLED_APPS = [
    'music',
    'blog',
    'homepage',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

This is my urls.py for the music/urls.py

from django.conf.urls import url, include
from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^contact/$', views.contact, name='contact'),
    url(r'^HomePage/$', views.HomePage, name='HomePage'),
]

This is the views.py music/views.py

from django.shortcuts import render

def index(request):
return render(request, 'music/home.html')

def contact(request):
return render(request, 'music/basic.html', {'content':['If you would like to contact me, please email me','@gmail.com']})

def HomePage(request):
return render(request, 'HomePage/homepage.html')

Here is my folder structure.

  |-.git
      |  |-hooks
      |  |-info
      |  |-logs
      |  |  |-refs
      |  |  |  |-heads
      |  |  |  |-remotes
      |  |  |  |  |-origin
      |  |-objects
      |  |  |-66
      |  |  |-a9
      |  |  |-aa
      |  |  |-e2
      |  |  |-e5
      |  |  |-info
      |  |  |-pack
      |  |-refs
      |  |  |-heads
      |  |  |-remotes
      |  |  |  |-origin
      |  |  |-tags
      |-.idea
      |  |-libraries
      |-__pycache__
      |-db
      |-DGLIB
      |  |-mysite
      |  |  |-blog
      |  |  |  |-__pycache__
      |  |  |  |-migrations
      |  |  |  |  |-__pycache__
      |  |  |  |-templates
      |  |  |  |  |-blog
      |  |  |-homepage
      |  |  |  |-__pycache__
      |  |  |  |-migrations
      |  |  |-music
      |  |  |  |-__pycache__
      |  |  |  |-migrations
      |  |  |  |  |-__pycache__
      |  |  |  |-static
      |  |  |  |  |-music
      |  |  |  |  |  |-css
      |  |  |  |  |  |-fonts
      |  |  |  |  |  |-img
      |  |  |  |  |  |-js
      |  |  |  |-templates
      |  |  |  |  |-music
      |  |  |  |  |  |-img
      |  |  |  |  |  |-includes
      |  |  |-mysite
      |  |  |  |-__pycache__
      |-model
      |  |-__pycache__
      |-notebooks
      |  |-.ipynb_checkpoints

Upvotes: 0

Views: 1506

Answers (1)

Prateek
Prateek

Reputation: 1556

Change this line:

url(r'^HomePage/',include('HomePage.urls')),

to

url(r'^HomePage/',include('homepage.urls')),

in your urls.py file, as you have 'homepage' as an app listed in your INSTALLED_APPS not 'HomePage'

Upvotes: 1

Related Questions