我目前正在使用Django在我的办公室制作表格。一切都很好,直到我发现访问网络时有任意随机数。
592
<html>
<head>
<title> Rekonsiliasi | Matching</title>
<style>
th{
text-align: center;
}
ul{
list-style-type: none;
}
</style>
因为它是使用Django中的模板渲染的,所以我尝试清空模板文件,但它仍然打印出来&#39; 0&#39;。
0
所以,我认为这不是模板问题。
对于发生了什么事的想法?
这是相关的python代码。
def choose(request,fl):
# fl is a form-name to show
if request.method == 'POST':
return saving(request,fl)
else:
return render(request,'rekonsi_db/choose.html',{'file' : fl})
这是我的settings.py
"""
Django settings for web 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
# import djcelery
from ConfigParser import RawConfigParser
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 = '#####'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
TEMPLATE_DIRS = (
'####',
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
ALLOWED_HOSTS = ['#####','####']
# Database configuration
config = RawConfigParser()
config.read('#####')
DATABASE_USER = config.get('database', 'DATABASE_USER')
DATABASE_PASSWORD = config.get('database', 'DATABASE_PASSWORD')
DATABASE_HOST = config.get('database', 'DATABASE_HOST')
DATABASE_PORT = config.get('database', 'DATABASE_PORT')
DATABASE_ENGINE = config.get('database', 'DATABASE_ENGINE')
DATABASE_OPENMRS = config.get('database', 'DATABASE_OPENMRS')
DATABASE_TEST = config.get('database', 'DATABASE_TEST')
DATABASE_PERSONNEL = config.get('database', 'DATABASE_PERSONNEL')
# Celery
BROKER_URL = '#####'
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'####',
'####',
'####',
'####',
'rekonsi_db'
# 'report',
)
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 = 'web.urls'
WSGI_APPLICATION = 'web.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 = 'Asia/Jakarta'
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/'
STATIC_ROOT = '####'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
#MEDIA
MEDIA_ROOT = '####'
MEDIA_URL = '/media/'
FILE_UPLOAD_TEMP_DIR = '#####'
FILE_UPLOAD_MAX_MEMORY_SIZE = 0
# Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '####',
'formatter': 'verbose'
},
'warning': {
'level': 'WARNING',
'class': 'logging.FileHandler',
'filename': '####',
'formatter': 'verbose'
},
},
'loggers': {
'django': {
'handlers':['file'],
'propagate': True,
'level':'DEBUG',
},
'gxp': {
'handlers': ['file', 'warning'],
'level': 'DEBUG',
},
}
}
这是我的urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
#####
url(r'^rekonsi_db/$','rekonsi_db.views.settings'),
url(r'^rekonsi_db/thanks/(\w+)/$','rekonsi_db.views.thanks'),
url(r'^rekonsi_db/choose/(\w+)/$','rekonsi_db.views.choose'),
url(r'^rekonsi_db/choose/(\w+)/api_yang_belum$','rekonsi_db.views.api_yang_belum'),
)
这是模板:
<html>
<head>
<title> Rekonsiliasi | Matching</title>
<style>
th{
text-align: center;
}
ul{
list-style-type: none;
}
</style>
{% load staticfiles %}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<link rel="stylesheet" href='{% static "rekonsi/simplePagination.css" %}'>
<!-- Latest compiled and minified JavaScript -->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src='{% static "rekonsi/index.js" %}'></script>
</head>
<body>
<div class='container'>
<div class='col-md-4'></div>
<div class='col-md-4' style='font-size : 14pt; text-align : center; margin : 4px;'> <h1>Rekonsiliasi Data</h1></div>
<div class='col-md-4'></div>
</div>
<form role='form' method='POST' class='form-group'>
{% csrf_token %}
<p hidden id='file_name'>{{file}}</p>
<div id='choosing' class='container' style='width:100%;'>
</div>
<input type='submit' id='submit'>
</form>
</body>
</html>
感谢任何帮助。我使用的是Django 1.6 (更新:它发生在整个django项目中)
答案 0 :(得分:0)
实际上,后来,我试图运行其他的django项目,并且遇到了同样的情况。
我试图重新启动笔记本电脑,再次运行此项目(以及其他项目),打印尺寸已消失。
但仍然不知道原因。
无论如何,感谢所有参与者!