Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pilot.views.py file
- def current_datetime(request):
- now = datetime.now();
- #html = "<html><body>The time is: %s.</body></html>" % now
- t = get_template("current_datetime.html")
- c = Context({"date": now})
- html = t.render(c)
- return HttpResponse(html)
- #current_datetime.html under templates directory in the project
- <html>
- <head>
- <title>Current date and time</title>
- </head>
- <body>
- The current time is {{date}}
- </body>
- </html>
- #settings.py
- """
- Django settings for pilot project.
- For more information on this file, see
- https://docs.djangoproject.com/en/1.6/topics/settings/
- For the full list of settings and their values, see
- https://docs.djangoproject.com/en/1.6/ref/settings/
- """
- # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
- import os
- BASE_DIR = os.path.dirname(os.path.dirname(__file__))
- # Quick-start development settings - unsuitable for production
- # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
- # SECURITY WARNING: keep the secret key used in production secret!
- SECRET_KEY = '=glaw6%x(w4y$@mqy7x&b03n+brhm!@s3$dtzk7j(-n(d#++1@'
- # SECURITY WARNING: don't run with debug turned on in production!
- DEBUG = True
- TEMPLATE_DEBUG = True
- PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
- TEMPLATES_DIR = [os.path.join(BASE_DIR, 'templates')]
- ALLOWED_HOSTS = []
- # Application definition
- INSTALLED_APPS = (
- 'pilot',
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- )
- MIDDLEWARE_CLASSES = (
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- )
- ROOT_URLCONF = 'pilot.urls'
- WSGI_APPLICATION = 'pilot.wsgi.application'
- # Database
- # https://docs.djangoproject.com/en/1.6/ref/settings/#databases
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
- }
- }
- # Internationalization
- # https://docs.djangoproject.com/en/1.6/topics/i18n/
- LANGUAGE_CODE = 'en-us'
- TIME_ZONE = 'UTC'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = True
- # Static files (CSS, JavaScript, Images)
- # https://docs.djangoproject.com/en/1.6/howto/static-files/
- STATIC_URL = '/static/'
- #traceback
- Environment:
- Request Method: GET
- Request URL: http://127.0.0.1:8000/date/
- Django Version: 1.6
- Python Version: 2.7.3
- Installed Applications:
- ('django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles')
- Installed Middleware:
- ('django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware')
- Template Loader Error:
- Django tried loading these templates, in this order:
- Using loader django.template.loaders.filesystem.Loader:
- Using loader django.template.loaders.app_directories.Loader:
- /usr/lib/python2.7/site-packages/django/contrib/admin/templates/current_datetime.html (File does not exist)
- /usr/lib/python2.7/site-packages/django/contrib/auth/templates/current_datetime.html (File does not exist)
- Traceback:
- File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
- 114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
- File "/home/oquidave/workspace/python/pilot/pilot/views.py" in current_datetime
- 10. t = get_template("current_datetime.html")
- File "/usr/lib/python2.7/site-packages/django/template/loader.py" in get_template
- 138. template, origin = find_template(template_name)
- File "/usr/lib/python2.7/site-packages/django/template/loader.py" in find_template
- 131. raise TemplateDoesNotExist(name)
- Exception Type: TemplateDoesNotExist at /date/
- Exception Value: current_datetime.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement