Ich kann nicht herausfinden, woher der Fehler kommt und das sind die letzten paar Dateien, die ich verpasst habe. Ich bekomme den ImportError: Kein Modul namens 'index'. ZurückImportError: Kein Modul namens 'index'
from django.conf.urls import url
from . import views
from .models import Album
urlpatterns = [
#/index.html/
url(r'^$', views.index ,name='index'),
#/index.html/71/
url(r'^(?P<album_id>[0-9]+)/$', views.details, name='detail')
]
________________________________ Ansichten __________________________________
from django.shortcuts import render
from django.http import HttpResponse
from .models import Album
from django.template import loader
# Create your views here.
def index(request):
all_albums = Album.objects.all()
template = loader.get_template('/music/index.html')
context = {
'all_albums': all_albums,
}
return HttpResponse(template.render(context,request))
def details(request, album_id):
return HttpResponse("<h2> details for album id: " + str(album_id) + "</h2>")
----------------------------- Trace - -------------------------------
Tyrees-MacBook-Pro:tyree_website tyreestevenson$ python3 manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x103b7eb70>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'index'
Können Sie die vollständige Traceback zeigen? – mgilson
Ich habe die Traceback @mgilson – user3697597
hinzugefügt Der Fehler scheint config verwandt zu sein. Suchen Sie dort nach einem "Index". –