For anyone who has this error, because static is variable it has to be enclosed with double curly brackets, not with percentage ones.
-- SOLUTION: change {% static('css/bootstrap.min.css') %} to {{ static('css/bootstrap.min.css') }}.
Dne čtvrtek 23. července 2015 3:36:52 UTC+2 Yitao Jiang napsal(a):
Dne čtvrtek 23. července 2015 3:36:52 UTC+2 Yitao Jiang napsal(a):
the same errorOn Thu, Jul 23, 2015 at 12:30 AM, James Schneider <jrschn...@gmail.com> wrote:Take out the parentheses () from your static tag.
-James
--On Jul 22, 2015 7:04 AM, "Yitao Jiang" <jiang...@gmail.com> wrote:You received this message because you are subscribed to the Google Groups "Django users" group.Do you guys have any idea?--
On Wednesday, July 22, 2015 at 3:47:38 PM UTC+8, Yitao Jiang wrote:Hi,I just followed the guide here https://docs.djangoproject.com/en/1.8/ , and all works fine.topics/templates/#django. template.backends.jinja2. Jinja2 But when i using static tag to parse the css files under static directory, reload the browser sayshere's my base.html snips<link href="{% static('css/bootstrap.min.css') %}" type="text/css" rel="stylesheet" /> settings.pyimport osDEBUG = TrueTEMPLATE_DEBUG = DEBUGROOT = os.path.dirname(os.path.dirname(os.path.abspath(__ file__))) path = lambda *a: os.path.join(ROOT, *a)MANAGERS = ADMINSDATABASES = {'default': {'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.'NAME': '', # Or path to database file if using sqlite3.'USER': '', # Not used with sqlite3.'PASSWORD': '', # Not used with sqlite3.'HOST': '', # Set to empty string for localhost. Not used with sqlite3.'PORT': '', # Set to empty string for default. Not used with sqlite3.}}# Hosts/domain names that are valid for this site; required if DEBUG is FalseALLOWED_HOSTS = []# Local time zone for this installation. Choices can be found here:# although not all choices may be available on all operating systems.# In a Windows environment this must be set to your system time zone.TIME_ZONE = 'America/Chicago'# Language code for this installation. All choices can be found here:LANGUAGE_CODE = 'en-us'SITE_ID = 1# If you set this to False, Django will make some optimizations so as not# to load the internationalization machinery.USE_I18N = True# If you set this to False, Django will not format dates, numbers and# calendars according to the current locale.USE_L10N = True# If you set this to False, Django will not use timezone-aware datetimes.USE_TZ = True# Absolute filesystem path to the directory that will hold user-uploaded files.# Example: "/home/media/media.lawrence.com/media/ "MEDIA_ROOT = ''# URL that handles the media served from MEDIA_ROOT. Make sure to use a# trailing slash.# Examples: "http://media.lawrence.com/media/ ", "http://example.com/media/"MEDIA_URL = ''# Absolute path to the directory static files should be collected to.# Don't put anything in this directory yourself; store your static files# in apps' "static/" subdirectories and in STATICFILES_DIRS.# Example: "/home/media/media.lawrence.com/static/ "STATIC_ROOT = "%s/static/" % path('.')# URL prefix for static files.# Example: "http://media.lawrence.com/static/ "STATIC_URL = '/static/'# Additional locations of static filesSTATICFILES_DIRS = (# Put strings here, like "/home/html/static" or "C:/www/django/static".# Always use forward slashes, even on Windows.# Don't forget to use absolute paths, not relative paths."%s/bumblebee/static/" % path('.'),)STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' # List of finder classes that know how to find static files in# various locations.STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )# Make this unique, and don't share it with anybody.SECRET_KEY = '08xs7wsdab!awp%f=_n5hqb#=_(w(^@=v&dnoi7jay=e85s(hw' TEMPLATES = [{'NAME': 'jinja2','BACKEND': 'django.template.backends.jinja2.Jinja2', 'APP_DIRS': True,'DIRS': ["%s/templates/jinja2" % path('.'),],'OPTIONS': {'autoescape': True,'auto_reload': DEBUG,'environment': 'bumblebee.jinja2.environment', },},{'NAME': 'django','BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [],'APP_DIRS': True,'OPTIONS': {'context_processors': ['django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.contrib.messages.context_processors.messages', ],},},]# List of callables that know how to import templates from various sources.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', )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', # Uncomment the next line for simple clickjacking protection:# 'django.middleware.clickjacking. XFrameOptionsMiddleware', )ROOT_URLCONF = 'bumblebee.urls'# Python dotted path to the WSGI application used by Django's runserver.WSGI_APPLICATION = 'bumblebee.wsgi.application'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.# os.path.join(os.path.dirname(__file__),'templates'), "%s/templates/" % path('.'),)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','jinja2',)# A sample logging configuration. The only tangible logging# performed by this configuration is to send an email to# the site admins on every HTTP 500 error when DEBUG=False.# more details on how to customize your logging configuration.LOGGING = {'version': 1,'disable_existing_loggers': False,'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse' }},'handlers': {'mail_admins': {'level': 'ERROR','filters': ['require_debug_false'],'class': 'django.utils.log.AdminEmailHandler' }},'loggers': {'django.request': {'handlers': ['mail_admins'],'level': 'ERROR','propagate': True,},}}belows is my django project topology
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c0631b7c- .bc54-4465-8077-0f559948ff42% 40googlegroups.com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/ .ECnrjgzHi8w/unsubscribe
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be% .2BciWzvDm4sNs6EzBorA7rb389ES- hqT%2BnPqn4aV0yLORW3A%40mail. gmail.com --
Regards,
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fcb929a5-7250-4bbd-bd31-28c26c02c929%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment