TemplateDoesNotExist

Django, Flask, Bottle, WSGI, CGI…
Antworten
Susanne
User
Beiträge: 35
Registriert: Dienstag 8. Januar 2013, 19:49

so, und nun zur nächsten Frage:
an was kann es leigen, dass die Meldung:
TemplateDoesNotExist
kommt?

Code: Alles auswählen

Python Path: 	

['/home/susanne/HomeView',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PIL',
 '/usr/lib/python2.7/dist-packages/gst-0.10',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
 '/usr/lib/python2.7/dist-packages/ubuntuone-couch',
 '/usr/lib/python2.7/dist-packages/ubuntuone-installer',
 '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
wie zu sehen ist, ist der Python Pfad gesetzt

der Pfad zu meiner index.html stimmt auch

Code: Alles auswählen

Exception Value: /Templates/Articles/index.html
allerdings kommt die Meldung dass TeplateDoesNotExist

kann mir jemand sagen was ich falsch mache
hier meine urls.py:

Code: Alles auswählen

 # Uncomment the next line to enable the Apps:
    url(r'^Articles/$', 'Articles.views.index'),
Hier meine views.py

Code: Alles auswählen

def index(request):
    "Create a list of the 5 latest articles"
    latest_articles_list = Article.objects.all().order_by('-pub_date')[:1]
    return render(request,'/Templates/Articles/index.html',{
    'latest_articles_list': latest_articles_list,
    })
und hier meine Settings.py

Code: Alles auswählen

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    #'/Articles/Templates',
    '/home/susanne/HomeView/Templates',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'Articles',
)

BlackJack

Also der Template Pfad ist ``/home/susanne/HomeView/Templates`` und Du willst das Template ``/Templates/Articles/index.htm`` unterhalb des Template-Pfads , also effektiv das Verzeichnis ``/home/susanne/HomeView/Templates/Templates/Articles/index.htm``. Nun überleg mal was daran falsch sein könnte.
Sirius3
User
Beiträge: 17747
Registriert: Sonntag 21. Oktober 2012, 17:20

@Susanne: jetzt hast Du aber noch nicht verraten, wo denn nun Deine index.html liegt:
1. /Templates/Articles/index.html
2. /home/susanne/HomeView/Templates/Articles/index.html
3. /home/susanne/HomeView/Templates/Templates/Articles/index.html
4. /home/susanne/HomeView/Articles/templates/Articles/index.html

unter 1. sucht Django das Template, unter 2. liegt es wohl, unter 3. würde er suchen, hättest Du den Pfad in »render« nicht absolut gemacht und unter 4. sollte es liegen.
Antworten