为什么int()参数必须是字符串或数字,而不是'list'?

时间:2014-11-16 11:45:52

标签: python django model-view-controller web django-forms

表单不能仅使用非空数据重新显示。为什么呢?

这是最小化的项目:

forms.py

from django import forms
from djangobug.models import P

class PForm(forms.Form):
    t = forms.CharField(max_length=255, required=True, widget=forms.TextInput())
    p = forms.ModelChoiceField(queryset=P.objects.all().order_by('n'), required=False, widget=forms.SelectMultiple())

models.py

# coding: utf-8
from django.db import models

class P(models.Model):
    n = models.CharField(max_length=255)

class I(models.Model):
    t = models.CharField(max_length=255)
    # p = models.ManyToManyField(P)
    p = models.ForeignKey(P)

urls.py

from django.conf.urls import patterns, url
from djangobug import views

urlpatterns = patterns('',
    url(r'^$', views.pview),
)

views.py

from django.core.context_processors import csrf
from django.shortcuts import render_to_response
from djangobug.forms import PForm


def pview(request):
    if request.POST:
        form = PForm(request.POST)
    else:
        form = PForm()
    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('pview.html', args)

pview.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

</body>
</html>

<form action="" method="post">
{% csrf_token %}
<ul>
{{ form.as_ul }}
</ul>
<input type="submit" name="submit" value="Submit" />
</form>


</body>
</html>

错误:

TypeError at /

int() argument must be a string or a number, not 'list'

Request Method:     POST
Request URL:    http://localhost:8000/
Django Version:     1.7.1
Exception Type:     TypeError
Exception Value:    

int() argument must be a string or a number, not 'list'

Exception Location:     /usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py in get_prep_value, line 915
Python Executable:  /usr/bin/python2.7
Python Version:     2.7.6
Python Path:    

['/home/user/src/djangobug',
 '/home/user/Installed/pycharm-3.4.1/helpers/pydev',
 '/usr/local/lib/python2.7/dist-packages/Trac-1.0.2-py2.7.egg',
 '/usr/lib/python2.7/dist-packages',
 '/usr/local/lib/python2.7/dist-packages/pudb-2014.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/urwid-1.3.0-py2.7-linux-x86_64.egg',
 '/home/user/src/djangobug',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.7',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']

Server time:    Sun, 16 Nov 2014 11:40:31 +0000
Error during template rendering

In template /home/user/src/djangobug/templates/pview.html, error at line 15
int() argument must be a string or a number, not 'list'
5   <title></title>
6   </head>
7   <body>
8   
9   </body>
10  </html>
11  
12  <form action="" method="post">
13  {% csrf_token %}
14  <ul>
15  {{ form.as_ul }}
16  </ul>
17  <input type="submit" name="submit" value="Submit" />
18  </form>
19  
20  
21  </body>
22  </html>
23  
24  
Traceback Switch back to interactive view
Environment: Request Method: POST Request URL: http://localhost:8000/ Django Version: 1.7.1 Python Version: 2.7.6 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'djangobug') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware') Template error: In template /home/user/src/djangobug/templates/pview.html, error at line 15 int() argument must be a string or a number, not 'list' 5 : <title></title> 6 : </head> 7 : <body> 8 : 9 : </body> 10 : </html> 11 : 12 : <form action="" method="post"> 13 : {% csrf_token %} 14 : <ul> 15 : {{ form.as_ul }} 16 : </ul> 17 : <input type="submit" name="submit" value="Submit" /> 18 : </form> 19 : 20 : 21 : </body> 22 : </html> 23 : 24 : Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 111. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/user/src/djangobug/djangobug/views.py" in pview 14. return render_to_response('pview.html', args) File "/usr/local/lib/python2.7/dist-packages/django/shortcuts.py" in render_to_response 23. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string 172. return t.render(Context(dictionary)) File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render 148. return self._render(context) File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render 142. return self.nodelist.render(context) File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render 844. bit = self.render_node(node, context) File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node 80. return node.render(context) File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render 90. output = self.filter_expression.resolve(context) File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in resolve 596. obj = self.var.resolve(context) File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in resolve 734. value = self._resolve_lookup(context) File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _resolve_lookup 788. current = current() File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in as_ul 266. errors_on_separate_row=False) File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in _html_output 181. top_errors = self.non_field_errors() # Errors that should be displayed above all fields. File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in non_field_errors 283. return self.errors.get(NON_FIELD_ERRORS, self.error_class()) File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in errors 154. self.full_clean() File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in full_clean 353. self._clean_fields() File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in _clean_fields 368. value = field.clean(value) File "/usr/local/lib/python2.7/dist-packages/django/forms/fields.py" in clean 150. value = self.to_python(value) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in to_python 1176. value = self.queryset.get(**{key: value}) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get 345. clone = self.filter(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in filter 691. return self._filter_or_exclude(False, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _filter_or_exclude 709. clone.query.add_q(Q(*args, **kwargs)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in add_q 1287. clause, require_inner = self._add_q(where_part, self.used_aliases) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in _add_q 1314. current_negated=current_negated, connector=connector) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in build_filter 1186. condition = self.build_lookup(lookups, col, value) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in build_lookup 1094. return final_lookup(lhs, rhs) File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py" in __init__ 82. self.rhs = self.get_prep_lookup() File "/usr/local/lib/python2.7/dist-packages/django/db/models/lookups.py" in get_prep_lookup 85. return self.lhs.output_field.get_prep_lookup(self.lookup_name, self.rhs) File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py" in get_prep_lookup 646. return self.get_prep_value(value) File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py" in get_prep_value 915. return int(value) Exception Type: TypeError at / Exception Value: int() argument must be a string or a number, not 'list'

Request information
GET

No GET data
POST
Variable    Value
p   

u''

csrfmiddlewaretoken     

u'IEDahenoKp7OewJ1cRTLBIO4N2vZoJtf'

t   

u'aaa'

submit  

u'Submit'

FILES

No FILES data
COOKIES
Variable    Value
csrftoken   

'IEDahenoKp7OewJ1cRTLBIO4N2vZoJtf'

sessionid   

'q07td9wz0q8judwqev1csozhzb3bh70m'

META
Variable    Value
RUN_MAIN    

'true'

HTTP_REFERER    

'http://localhost:8000/'

XDG_GREETER_DATA_DIR    

'/var/lib/lightdm-data/user'

QT4_IM_MODULE   

'xim'

SERVER_SOFTWARE     

'WSGIServer/0.1 Python/2.7.6'

UPSTART_EVENTS  

'started xsession'

SCRIPT_NAME     

u''

REQUEST_METHOD  

'POST'

GVM_PLATFORM    

'Linux'

SERVER_PROTOCOL     

'HTTP/1.1'

LC_PAPER    

'en_GB.UTF-8'

HOME    

'/home/user'

DISPLAY     

':0.0'

GVM_BROKER_SERVICE  

'http://release.gvm.io'

LANG    

'en_GB.UTF-8'

SHELL   

'/bin/bash'

XDG_DATA_DIRS   

'/usr/share/xubuntu:/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share'

MANDATORY_PATH  

'/usr/share/gconf/xubuntu.mandatory.path'

GVM_INIT    

'true'

TEXTDOMAIN  

'im-config'

UPSTART_INSTANCE    

''

JOB     

'dbus'

SESSION     

'xubuntu'

LAZYBONES_HOME  

'/home/user/.gvm/lazybones/current'

SERVER_PORT     

'8000'

XMODIFIERS  

'@im=ibus'

JAVA_HOME   

'/usr/lib/jvm/java-7-openjdk-amd64'

SELINUX_INIT    

'YES'

PATH_INFO   

u'/'

XDG_RUNTIME_DIR     

'/run/user/1000'

GTK_IM_MODULE   

'ibus'

LC_ADDRESS  

'en_GB.UTF-8'

PYTHONPATH  

'/home/user/src/djangobug'

GROOVY_HOME     

'/home/user/.gvm/groovy/current'

GVM_SERVICE     

'http://api.gvmtool.net'

HTTP_HOST   

'localhost:8000'

GNOME_KEYRING_PID   

'2286'

wsgi.version    

(1, 0)

XDG_CURRENT_DESKTOP     

'XFCE'

XDG_SESSION_ID  

'c2'

DBUS_SESSION_BUS_ADDRESS    

'unix:abstract=/tmp/dbus-grJcA4iTdB'

GTK_MODULES     

'overlay-scrollbar'

HTTP_ACCEPT     

'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'

DESKTOP_SESSION     

'xubuntu'

CRASH_HOME  

'/home/user/.gvm/crash/current'

LESSCLOSE   

'/usr/bin/lesspipe %s %s'

DEFAULTS_PATH   

'/usr/share/gconf/xubuntu.default.path'

wsgi.run_once   

False

wsgi.errors     

<open file '<stderr>', mode 'w' at 0x7f954c8fc1e0>

wsgi.multiprocess   

False

HTTP_ACCEPT_LANGUAGE    

'en-GB,en;q=0.5'

VERTX_HOME  

'/home/user/.gvm/vertx/current'

PYCHARM_HOSTED  

'1'

GVM_DIR     

'/home/user/.gvm'

PAPERSIZE   

'a4'

INSTANCE    

''

wsgi.input  

<socket._fileobject object at 0x7f953a1895d0>

LC_NAME     

'en_GB.UTF-8'

XDG_MENU_PREFIX     

'xfce-'

GROOVYSERV_HOME     

'/home/user/.gvm/groovyserv/current'

GRAILS_HOME     

'/home/user/.gvm/grails/current'

XDG_SEAT    

'seat0'

LC_NUMERIC  

'en_GB.UTF-8'

GAIDEN_HOME     

'/home/user/.gvm/gaiden/current'

GLADE_PIXMAP_PATH   

':'

HTTP_COOKIE     

'csrftoken=IEDahenoKp7OewJ1cRTLBIO4N2vZoJtf; sessionid=q07td9wz0q8judwqev1csozhzb3bh70m'

LESSOPEN    

'| /usr/bin/lesspipe %s'

QUERY_STRING    

''

QT_IM_MODULE    

'ibus'

LOGNAME     

'user'

USER    

'user'

PATH    

'/home/user/.gvm/vertx/current/bin:/home/user/.gvm/springboot/current/bin:/home/user/.gvm/lazybones/current/bin:/home/user/.gvm/jbake/current/bin:/home/user/.gvm/groovyserv/current/bin:/home/user/.gvm/groovy/current/bin:/home/user/.gvm/griffon/current/bin:/home/user/.gvm/grails/current/bin:/home/user/.gvm/gradle/current/bin:/home/user/.gvm/glide/current/bin:/home/user/.gvm/gaiden/current/bin:/home/user/.gvm/crash/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-7-openjdk-amd64/bin:/home/user/Installed/activator-1.2.10-minimal'

XDG_VTNR    

'7'

GNOME_KEYRING_CONTROL   

'/run/user/1000/keyring-qY27r6'

PYTHONUNBUFFERED    

'1'

UPSTART_SESSION     

'unix:abstract=/com/ubuntu/upstart-session/1000/2293'

TERM    

'emacs'

HTTP_USER_AGENT     

'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0'

XDG_SESSION_PATH    

'/org/freedesktop/DisplayManager/Session0'

XAUTHORITY  

'/home/user/.Xauthority'

LANGUAGE    

'en_GB:en'

SESSION_MANAGER     

'local/ThinkPad:@/tmp/.ICE-unix/2454,unix/ThinkPad:/tmp/.ICE-unix/2454'

LC_MEASUREMENT  

'en_GB.UTF-8'

CONTENT_TYPE    

'application/x-www-form-urlencoded'

QT_QPA_PLATFORMTHEME    

'appmenu-qt5'

LD_LIBRARY_PATH     

'/home/user/Installed/pycharm-3.4.1/bin:'

wsgi.url_scheme     

'http'

CLUTTER_IM_MODULE   

'xim'

WINDOWID    

'83886716'

GLIDE_HOME  

'/home/user/.gvm/glide/current'

SESSIONTYPE     

''

IM_CONFIG_PHASE     

'1'

GLADE_CATALOG_PATH  

':'

GPG_AGENT_INFO  

'/run/user/1000/keyring-qY27r6/gpg:0:1'

CONTENT_LENGTH  

'75'

SHLVL   

'1'

GRIFFON_HOME    

'/home/user/.gvm/griffon/current'

GLADE_MODULE_PATH   

':'

GVM_VERSION     

'2.2.0'

SSH_AUTH_SOCK   

'/run/user/1000/keyring-qY27r6/ssh'

CLASSPATH   

'/home/user/Installed/pycharm-3.4.1/bin/../lib/bootstrap.jar:/home/user/Installed/pycharm-3.4.1/bin/../lib/extensions.jar:/home/user/Installed/pycharm-3.4.1/bin/../lib/util.jar:/home/user/Installed/pycharm-3.4.1/bin/../lib/jdom.jar:/home/user/Installed/pycharm-3.4.1/bin/../lib/log4j.jar:/home/user/Installed/pycharm-3.4.1/bin/../lib/trove4j.jar:/home/user/Installed/pycharm-3.4.1/bin/../lib/jna.jar'

GDMSESSION  

'xubuntu'

UPSTART_JOB     

'startxfce4'

TEXTDOMAINDIR   

'/usr/share/locale/'

wsgi.multithread    

True

XDG_SEAT_PATH   

'/org/freedesktop/DisplayManager/Seat0'

TZ  

'UTC'

SPRINGBOOT_HOME     

'/home/user/.gvm/springboot/current'

_   

'/home/user/Installed/pycharm-3.4.1/bin/pycharm.sh'

HTTP_CONNECTION     

'keep-alive'

LC_IDENTIFICATION   

'en_GB.UTF-8'

GRADLE_HOME     

'/home/user/.gvm/gradle/current'

LS_COLORS   

'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:'

XDG_CONFIG_DIRS     

'/etc/xdg/xdg-xubuntu:/usr/share/upstart/xdg:/etc/xdg:/etc/xdg'

SERVER_NAME     

'localhost'

GATEWAY_INTERFACE   

'CGI/1.1'

CSRF_COOKIE     

u'IEDahenoKp7OewJ1cRTLBIO4N2vZoJtf'

REMOTE_ADDR     

'127.0.0.1'

GDM_LANG    

'en_GB'

LC_TELEPHONE    

'en_GB.UTF-8'

CSRF_COOKIE_USED    

True

PYTHONIOENCODING    

'UTF-8'

LC_MONETARY     

'en_GB.UTF-8'

PWD     

'/home/user'

JBAKE_HOME  

'/home/user/.gvm/jbake/current'

DJANGO_SETTINGS_MODULE  

'djangobug.settings'

COLORTERM   

'xfce4-terminal'

GVM_BROADCAST_SERVICE   

'http://cast.gvm.io'

LC_TIME     

'en_GB.UTF-8'

wsgi.file_wrapper   

''

REMOTE_HOST     

''

HTTP_ACCEPT_ENCODING    

'gzip, deflate'

Settings
Using settings module djangobug.settings
Setting     Value
USE_L10N    

True

USE_THOUSAND_SEPARATOR  

False

CSRF_COOKIE_SECURE  

False

LANGUAGE_CODE   

'en-us'

ROOT_URLCONF    

'djangobug.urls'

MANAGERS    

()

BASE_DIR    

'/home/user/src/djangobug'

TEST_NON_SERIALIZED_APPS    

[]

DEFAULT_CHARSET     

'utf-8'

SESSION_SERIALIZER  

'django.contrib.sessions.serializers.JSONSerializer'

STATIC_ROOT     

None

ALLOWED_HOSTS   

[]

MESSAGE_STORAGE     

'django.contrib.messages.storage.fallback.FallbackStorage'

EMAIL_SUBJECT_PREFIX    

'[Django] '

SEND_BROKEN_LINK_EMAILS     

False

STATICFILES_FINDERS     

('django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder')

SESSION_CACHE_ALIAS     

'default'

SESSION_COOKIE_DOMAIN   

None

SESSION_COOKIE_NAME     

'sessionid'

ADMIN_FOR   

()

TIME_INPUT_FORMATS  

('%H:%M:%S', '%H:%M:%S.%f', '%H:%M')

DATABASES   

{'default': {'ATOMIC_REQUESTS': False,
         'AUTOCOMMIT': True,
         'CONN_MAX_AGE': 0,
         'ENGINE': 'django.db.backends.sqlite3',
         'HOST': '',
         'NAME': '/home/user/src/djangobug/db.sqlite3',
         'OPTIONS': {},
         'PASSWORD': u'********************',
         'PORT': '',
         'TEST': {'CHARSET': None,
                  'COLLATION': None,
                  'MIRROR': None,
                  'NAME': None},
         'TIME_ZONE': 'UTC',
         'USER': ''}}

FILE_UPLOAD_DIRECTORY_PERMISSIONS   

None

FILE_UPLOAD_PERMISSIONS     

None

FILE_UPLOAD_HANDLERS    

('django.core.files.uploadhandler.MemoryFileUploadHandler',
 'django.core.files.uploadhandler.TemporaryFileUploadHandler')

DEFAULT_CONTENT_TYPE    

'text/html'

APPEND_SLASH    

True

LOCALE_PATHS    

()

DATABASE_ROUTERS    

[]

DEFAULT_TABLESPACE  

''

YEAR_MONTH_FORMAT   

'F Y'

STATICFILES_STORAGE     

'django.contrib.staticfiles.storage.StaticFilesStorage'

CACHES  

{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}

SERVER_EMAIL    

'root@localhost'

SESSION_COOKIE_PATH     

'/'

SILENCED_SYSTEM_CHECKS  

[]

MIDDLEWARE_CLASSES  

('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')

USE_I18N    

True

THOUSAND_SEPARATOR  

','

SECRET_KEY  

u'********************'

LANGUAGE_COOKIE_NAME    

'django_language'

DEFAULT_INDEX_TABLESPACE    

''

TRANSACTIONS_MANAGED    

False

LOGGING_CONFIG  

'logging.config.dictConfig'

TEMPLATE_LOADERS    

('django.template.loaders.filesystem.Loader',
 'django.template.loaders.app_directories.Loader')

FIRST_DAY_OF_WEEK   

0

WSGI_APPLICATION    

'djangobug.wsgi.application'

TEMPLATE_DEBUG  

True

X_FRAME_OPTIONS     

'SAMEORIGIN'

CSRF_COOKIE_NAME    

'csrftoken'

FORCE_SCRIPT_NAME   

None

USE_X_FORWARDED_HOST    

False

SIGNING_BACKEND     

'django.core.signing.TimestampSigner'

SESSION_COOKIE_SECURE   

False

CSRF_COOKIE_DOMAIN  

None

FILE_CHARSET    

'utf-8'

DEBUG   

True

LANGUAGE_COOKIE_DOMAIN  

None

DEFAULT_FILE_STORAGE    

'django.core.files.storage.FileSystemStorage'

INSTALLED_APPS  

('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'djangobug')

LANGUAGES   

(('af', 'Afrikaans'),
 ('ar', 'Arabic'),
 ('ast', 'Asturian'),
 ('az', 'Azerbaijani'),
 ('bg', 'Bulgarian'),
 ('be', 'Belarusian'),
 ('bn', 'Bengali'),
 ('br', 'Breton'),
 ('bs', 'Bosnian'),
 ('ca', 'Catalan'),
 ('cs', 'Czech'),
 ('cy', 'Welsh'),
 ('da', 'Danish'),
 ('de', 'German'),
 ('el', 'Greek'),
 ('en', 'English'),
 ('en-au', 'Australian English'),
 ('en-gb', 'British English'),
 ('eo', 'Esperanto'),
 ('es', 'Spanish'),
 ('es-ar', 'Argentinian Spanish'),
 ('es-mx', 'Mexican Spanish'),
 ('es-ni', 'Nicaraguan Spanish'),
 ('es-ve', 'Venezuelan Spanish'),
 ('et', 'Estonian'),
 ('eu', 'Basque'),
 ('fa', 'Persian'),
 ('fi', 'Finnish'),
 ('fr', 'French'),
 ('fy', 'Frisian'),
 ('ga', 'Irish'),
 ('gl', 'Galician'),
 ('he', 'Hebrew'),
 ('hi', 'Hindi'),
 ('hr', 'Croatian'),
 ('hu', 'Hungarian'),
 ('ia', 'Interlingua'),
 ('id', 'Indonesian'),
 ('io', 'Ido'),
 ('is', 'Icelandic'),
 ('it', 'Italian'),
 ('ja', 'Japanese'),
 ('ka', 'Georgian'),
 ('kk', 'Kazakh'),
 ('km', 'Khmer'),
 ('kn', 'Kannada'),
 ('ko', 'Korean'),
 ('lb', 'Luxembourgish'),
 ('lt', 'Lithuanian'),
 ('lv', 'Latvian'),
 ('mk', 'Macedonian'),
 ('ml', 'Malayalam'),
 ('mn', 'Mongolian'),
 ('mr', 'Marathi'),
 ('my', 'Burmese'),
 ('nb', 'Norwegian Bokmal'),
 ('ne', 'Nepali'),
 ('nl', 'Dutch'),
 ('nn', 'Norwegian Nynorsk'),
 ('os', 'Ossetic'),
 ('pa', 'Punjabi'),
 ('pl', 'Polish'),
 ('pt', 'Portuguese'),
 ('pt-br', 'Brazilian Portuguese'),
 ('ro', 'Romanian'),
 ('ru', 'Russian'),
 ('sk', 'Slovak'),
 ('sl', 'Slovenian'),
 ('sq', 'Albanian'),
 ('sr', 'Serbian'),
 ('sr-latn', 'Serbian Latin'),
 ('sv', 'Swedish'),
 ('sw', 'Swahili'),
 ('ta', 'Tamil'),
 ('te', 'Telugu'),
 ('th', 'Thai'),
 ('tr', 'Turkish'),
 ('tt', 'Tatar'),
 ('udm', 'Udmurt'),
 ('uk', 'Ukrainian'),
 ('ur', 'Urdu'),
 ('vi', 'Vietnamese'),
 ('zh-cn', 'Simplified Chinese'),
 ('zh-hans', 'Simplified Chinese'),
 ('zh-hant', 'Traditional Chinese'),
 ('zh-tw', 'Traditional Chinese'))

COMMENTS_ALLOW_PROFANITIES  

False

STATICFILES_DIRS    

()

PREPEND_WWW     

False

SECURE_PROXY_SSL_HEADER     

None

LANGUAGE_COOKIE_AGE     

None

SESSION_COOKIE_HTTPONLY     

True

DEBUG_PROPAGATE_EXCEPTIONS  

False

INTERNAL_IPS    

()

MONTH_DAY_FORMAT    

'F j'

LOGIN_URL   

'/accounts/login/'

SESSION_EXPIRE_AT_BROWSER_CLOSE     

False

TIME_FORMAT     

'P'

AUTH_USER_MODEL     

'auth.User'

DATE_INPUT_FORMATS  

('%Y-%m-%d',
 '%m/%d/%Y',
 '%m/%d/%y',
 '%b %d %Y',
 '%b %d, %Y',
 '%d %b %Y',
 '%d %b, %Y',
 '%B %d %Y',
 '%B %d, %Y',
 '%d %B %Y',
 '%d %B, %Y')

AUTHENTICATION_BACKENDS     

('django.contrib.auth.backends.ModelBackend',)

EMAIL_HOST_PASSWORD     

u'********************'

PASSWORD_RESET_TIMEOUT_DAYS     

u'********************'

SESSION_FILE_PATH   

None

CACHE_MIDDLEWARE_ALIAS  

'default'

SESSION_SAVE_EVERY_REQUEST  

False

NUMBER_GROUPING     

0

SESSION_ENGINE  

'django.contrib.sessions.backends.db'

CSRF_FAILURE_VIEW   

'django.views.csrf.csrf_failure'

CSRF_COOKIE_PATH    

'/'

LOGIN_REDIRECT_URL  

'/accounts/profile/'

DECIMAL_SEPARATOR   

'.'

IGNORABLE_404_URLS  

()

MIGRATION_MODULES   

{}

TEMPLATE_STRING_IF_INVALID  

''

LOGOUT_URL  

'/accounts/logout/'

EMAIL_USE_TLS   

False

FIXTURE_DIRS    

()

EMAIL_HOST  

'localhost'

DATE_FORMAT     

'N j, Y'

MEDIA_ROOT  

''

DEFAULT_EXCEPTION_REPORTER_FILTER   

'django.views.debug.SafeExceptionReporterFilter'

ADMINS  

()

FORMAT_MODULE_PATH  

None

DEFAULT_FROM_EMAIL  

'webmaster@localhost'

MEDIA_URL   

''

DATETIME_FORMAT     

'N j, Y, P'

TEMPLATE_DIRS   

('/home/user/src/djangobug/templates',)

DISALLOWED_USER_AGENTS  

()

ALLOWED_INCLUDE_ROOTS   

()

LOGGING     

{}

SHORT_DATE_FORMAT   

'm/d/Y'

TEST_RUNNER     

'django.test.runner.DiscoverRunner'

CACHE_MIDDLEWARE_KEY_PREFIX     

u'********************'

TIME_ZONE   

'UTC'

FILE_UPLOAD_MAX_MEMORY_SIZE     

2621440

EMAIL_BACKEND   

'django.core.mail.backends.smtp.EmailBackend'

EMAIL_USE_SSL   

False

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.core.context_processors.tz',
 'django.contrib.messages.context_processors.messages')

SESSION_COOKIE_AGE  

1209600

SETTINGS_MODULE     

'djangobug.settings'

USE_ETAGS   

False

LANGUAGES_BIDI  

('he', 'ar', 'fa', 'ur')

FILE_UPLOAD_TEMP_DIR    

None

CSRF_COOKIE_AGE     

31449600

STATIC_URL  

'/static/'

EMAIL_PORT  

25

USE_TZ  

True

SHORT_DATETIME_FORMAT   

'm/d/Y P'

PASSWORD_HASHERS    

u'********************'

ABSOLUTE_URL_OVERRIDES  

{}

LANGUAGE_COOKIE_PATH    

'/'

CACHE_MIDDLEWARE_SECONDS    

600

CSRF_COOKIE_HTTPONLY    

False

DATETIME_INPUT_FORMATS  

('%Y-%m-%d %H:%M:%S',
 '%Y-%m-%d %H:%M:%S.%f',
 '%Y-%m-%d %H:%M',
 '%Y-%m-%d',
 '%m/%d/%Y %H:%M:%S',
 '%m/%d/%Y %H:%M:%S.%f',
 '%m/%d/%Y %H:%M',
 '%m/%d/%Y',
 '%m/%d/%y %H:%M:%S',
 '%m/%d/%y %H:%M:%S.%f',
 '%m/%d/%y %H:%M',
 '%m/%d/%y')

EMAIL_HOST_USER     

''

PROFANITIES_LIST    

u'********************'

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 500 page.

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

1 个答案:

答案 0 :(得分:0)

尝试在PForm课程中使用ModelMultipleChoiceField而不是ModelChoiceField