Python Django:渲染打印随机数和0

Python Django:渲染打印随机数和0,python,django,Python,Django,我目前正在使用Django在我的办公室制作表单。一切都很好,直到我意识到当我访问网络时有任何随机数 592 <html> <head> <title> Rekonsiliasi | Matching</title> <style> th{ text-align: center; } ul{

我目前正在使用Django在我的办公室制作表单。一切都很好,直到我意识到当我访问网络时有任何随机数

592
<html>
    <head>
        <title> Rekonsiliasi | Matching</title>
        <style>
            th{
                text-align: center;
            }
            ul{
                list-style-type: none;
            }
        </style>
所以,我认为这不是模板的问题

知道发生了什么事吗

这是相关的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})
这是我的设置.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',
        },
    }
}
这是我的URL.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>

Rekonsiliasi |匹配
th{
文本对齐:居中;
}
保险商实验室{
列表样式类型:无;
}
{%load staticfiles%}
Rekonsiliasi数据
{%csrf_令牌%}

感谢您的帮助。我正在使用Django 1.6
(更新:这发生在整个django项目上)

事实上,后来,我尝试运行我的另一个django项目,也遇到了同样的情况

我试着重新启动我的笔记本电脑,再次运行这个项目(还有其他项目),但打印的尺寸消失了

但还是不知道原因


无论如何,谢谢大家的参与

因此,在浏览器中查看HTML页面时,您似乎获得了作为第一次输出传输的字节数(猜测)。您是如何通过开发服务器运行Django:的?你的设置是什么样子的?你的URL.py是什么?看起来很正常,但顶部和底部都有一个随机数。我不能发布图片,所以我放了一个页面源代码@DanielRoseman@Evert是的,通过开发服务器。我已经把设置和URL放在我的帖子里了。你知道吗?你能看看开发服务器的日志和你在第一行看到的数字之间是否有对应关系吗?例如,服务器将发送的字节数记录为行中的最后一个数字。实际上,您希望它再次出现,因为否则这可能会发生在生产服务器上,并造成比现在更大的痛苦。
    <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>