TemplateSyntaxError 'staticfiles' ist kein Gültiger tag-Bibliothek'

Ich habe da ein wirklich seltsames Problem, zu versuchen, um die staticfiles taglib funktioniert in meiner Anwendung. Ich bin im wesentlichen immer die folgende Fehlermeldung:

'staticfiles' is not a valid tag library: Template library staticfiles not found, tried django.templatetags.staticfiles,django.contrib.admin.templatetags.staticfiles

Hier ist meine Vorlage, die wirft diesen Fehler:

{% load staticfiles %}
<html>
    <head>
        {% block stylesheets %}
        <link rel="stylesheet" href="{% static "styles/bootstrap-1.2.0.min.css" %}">
        {% endblock %}
        <title>{% block title %}Tzibor{% endblock %}</title>
    </head>
    <body>
        <h1>It Works!</h1>
        {% block scripts %}
        <script type="text/javascript" src="{% static "scripts/jquery-1.6.2.min.js" %}"></script>
        {% endblock %}
    </body>
</html>

Hier mein settings.py:

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (

)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': '/tmp/project.db',
        'USER': '',                    
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

TIME_ZONE = 'UTC'
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

USE_I18N = True
USE_L10N = True
MEDIA_ROOT = '' # abs fs path to upload dir
MEDIA_URL = ''
STATIC_URL = '/static/'

ADMIN_MEDIA_PREFIX = '/media/'

SECRET_KEY = '4qo&twl!=ty!n%1@h2nidz^ie@$^uu@*pz)(ol%ise0&g6*@&_'

#TEMPLATE_CONTEXT_PROCESSORS = (
#   "django.contrib.auth.context_processors.auth",
#   "django.core.context_processors.debug",
#   "django.core.context_processors.i18n",
#   "django.core.context_processors.media",
#   "django.core.context_processors.static",
#   "django.contrib.messages.context_processors.messages",
#)

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.eggs.Loader',
)

TEMPLATE_DIRS = (

)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'project.urls'

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'django.contrib.staticfiles',
    'project.web',
    'south',
)

Im wesentlichen, folgte ich der Anleitung in der Django-Dokumentation zum einrichten der statischen Anwendung dienen, und habe diesen Fehler. Kann jemand sehen, was das Problem ist? Bin ich etwas fehlt?

Vollständigen stacktrace hier.

  • Was passiert, wenn du gehst in die shell und geben Sie import staticfiles?
  • Ich denke mal, dass du nicht die STATIC_ROOT Wert in den Einstellungen. Tut manage.py collectstatic funktionieren?
  • Reiter, ImportError: No module named staticfiles.
  • dieses Problem hatte, es fest, aber immer noch der Fehler.
  • Versuchen import django.contrib.staticfiles.templatetags.staticfiles im python manage.py shell
  • Es gibt kein solches Paket als "templatetags.staticfiles" in "django.contrib.staticfiles". Ich bin mit Dingen in Buildout, so ist es ein anderes Paket, andere als Django-die richtige, welche muss ich nehmen? Ich bin mit Django 1.3.
  • Meine Vermutung ist, dass es etwas falsch mit Ihrem Django installieren. Ich würde tun, eine Neuinstallation von Django und sehen, was passiert.
  • AFAIK ist Dies neu in der Entwickler-version nicht in 1.3. Siehe Die erste Zeile nach dem statische tag-in den docs und vergleichen Sie die doc-version 1.3.
  • Ich habe was zu sein scheint der tag: django.templatetags.static.py.
  • Ich werde check it out.
  • Das war der trick. Es ist seltsam, dass Django die docs standardmäßig über dev eher als Ihre neueste releas.
  • Eine Antwort über mit {% load static %} und {% get_static_prefix %} und ich werde dir die Antwort geben.

InformationsquelleAutor Naftuli Kay | 2011-09-06
Schreibe einen Kommentar