保存对象时,'BoundField'对象没有属性'_committed'

时间:2016-05-29 15:47:04

标签: python django django-models django-views django-database

我遇到了保存对象delivery的问题。

所以我有两个对象 - JobDelivery。在传递job实例时,job.delivery中会发生一些更改。

一切正常 - delivery_form有效,找到job个对象,找到delivery个对象。唯一的问题是当我尝试保存delivery对象,因为它已被更改。

Exception Value:   'BoundField' object has no attribute '_committed'

注意:我已经尝试以另一种方式获取deliveryDelivery.objects.get(job=job) - 它没有改变任何内容。

我在这个问题的底部添加了错误追溯。你知道问题出在哪里吗?

这是一个观点:

@login_required
def deliver_job(request, id): 
    deliver_form = DeliverForm(request.POST or None, request.FILES or None)

    if request.method == 'POST':
        if deliver_form.is_valid():
            job = Job.objects.get(id=id)
            notes = deliver_form.cleaned_data['notes']
            uploaded_file = deliver_form['uploaded_file']
            delivery = job.delivery
            delivery.notes_by_translator = notes
            delivery.file = uploaded_file
            delivery.status = 'delivered'
            delivery.save() # HERE IS THE PROBLEM
            return HttpResponseRedirect('/profile/' + request.user.username + '/')
        else:
            print deliver_form.errors
    context = {'deliver_form': deliver_form}

    return render(request, 'auth/jobs/deliver-job.html', context=context)

投放:

class Delivery(models.Model):
    job = models.OneToOneField(Job, related_name='delivery',on_delete=models.CASCADE)
    notes_by_translator = models.TextField(blank=True, null=True)
    notes_by_customer = models.TextField(blank=True, null=True)
    rating_percent = models.IntegerField(blank=True, null=True)
    file = models.FileField(null=True,blank=True)
    STATUS_CHOICES = (('pending', 'Pending'),
                      ('translator_assigned','Translator Assigned'),
                      ('delivered', 'Delivered'),
                      ('closed', 'Closed'),

                      ('reopened', 'Reopened'),
                      ('canceled', 'Canceled'),
                      )

    status = models.CharField(max_length=60, choices=STATUS_CHOICES,default='pending')

作业:

class Job(models.Model):
    customer = models.ForeignKey(User, related_name='orders', help_text=_("Customer"), on_delete=models.CASCADE)
    translator = models.ForeignKey(User, related_name='jobs', null=True, blank=True, help_text=_(u"Translator"))
    price = models.FloatField(null=True, blank=True, help_text=_(u"Price"))

    language_from = models.ForeignKey(Language, related_name='jobs_from', null=True)
    language_to = models.ForeignKey(Language, related_name='jobs_to', null=True)

    # ZADAVA CUSTOMER
    short_description = models.CharField(max_length=40, blank=False,
                                         help_text=_(u"Very short description of this order"))
    notes = models.TextField(help_text=_("Notes"))
    text_to_translate = models.TextField(verbose_name='Text to translate', blank=True, null=True,
                                         help_text=u"Text, ktorý chcete preložiť (ak neprikladáte súbor).")
    file = models.FileField(null=True, blank=True, help_text=u"Upload file")
    level = models.ForeignKey(Level, null=False, default=None)

    PROGRESS_CHOICES = (

        ('translator_not_assigned_yet', 'Translator not assigned yet'),
        ('in_translation_process', 'In translation process'),
        ('translated', 'Translated'),
        ('complete', 'Complete')
    )

    progress = models.CharField(choices=PROGRESS_CHOICES, max_length=40, default='translator_not_assigned_yet')

    # AUTOMATICKY GENEROVANE
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

    is_active = models.BooleanField(default=False)

    is_done = models.BooleanField(default=False)

    @property
    def has_translator(self):
        return self.translator_id is not None

    def __str__(self):
        return '{}: {} to {} | {}'.format(self.customer, self.language_from, self.language_to, self.short_description)

错误跟踪

AttributeError at /deliver-job/23
'BoundField' object has no attribute '_committed'
Request Method: POST
Request URL:    http://127.0.0.1:8000/deliver-job/23
Django Version: 1.8.12
Exception Type: AttributeError
Exception Value:    
'BoundField' object has no attribute '_committed'
Exception Location: C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\lib\site-packages\django\db\models\fields\files.py in pre_save, line 312
Python Executable:  C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\Scripts\python.exe
Python Version: 2.7.10
Python Path:    
['C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\lib\\site-packages\\django_quiz_app-0.5.1-py2.7.egg',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\lib\\site-packages\\pillow-2.5.0-py2.7-win32.egg',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\lib\\site-packages\\django_model_utils-2.0.3-py2.7.egg',
 'C:\\WINDOWS\\SYSTEM32\\python27.zip',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\DLLs',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\lib',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\lib\\plat-win',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\lib\\lib-tk',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\Scripts',
 'c:\\python27\\Lib',
 'c:\\python27\\DLLs',
 'c:\\python27\\Lib\\lib-tk',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv',
 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\lib\\site-packages']
Server time:    Sun, 29 May 2016 17:43:23 +0200
Traceback Switch back to interactive view


Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/deliver-job/23

Django Version: 1.8.12
Python Version: 2.7.10
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'SolutionsForLanguagesApp',
 'quiz',
 'crispy_forms',
 'super_inlines',
 'django_tables2',
 'essay',
 'multichoice',
 'true_false',
 'smart_selects',
 'django_extensions')
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',
 'django.middleware.security.SecurityMiddleware',
 'django.middleware.locale.LocaleMiddleware')


Traceback:
File "C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\lib\site-packages\django\core\handlers\base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)
File "C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\SolutionsForLanguagesApp\views.py" in deliver_job
  354.                 delivery.save()
File "C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\lib\site-packages\django\db\models\base.py" in save
  734.                        force_update=force_update, update_fields=update_fields)
File "C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\lib\site-packages\django\db\models\base.py" in save_base
  762.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\lib\site-packages\django\db\models\base.py" in _save_table
  824.                       for f in non_pks]
File "C:\Users\Milano\PycharmProjects\FutileStudio\SolutionsForLanguages_2\venv\lib\site-packages\django\db\models\fields\files.py" in pre_save
  312.         if file and not file._committed:

Exception Type: AttributeError at /deliver-job/23
Exception Value: 'BoundField' object has no attribute '_committed'



Share this traceback on a public Web site
Request information

GET
No GET data
POST
Variable    Value
csrfmiddlewaretoken 
u'U9fbDLXpsFlx5duvaxlVns1b0SPMZZ8x'
notes   
u'dsdsadsa'
FILES
Variable    Value
uploaded_file   
<InMemoryUploadedFile: diagram.PNG (image/png)>
COOKIES
Variable    Value
csrftoken   
'U9fbDLXpsFlx5duvaxlVns1b0SPMZZ8x'
sessionid   
'v0w7l15uhc4461nfgf8sbnd216qh447e'
TawkConnectionTime  
'0'
__tawkuuid  
'e::127.0.0.1::BOXGnOXlC+sZ1MnGIBfHRSpvgi8UQU4rXEVrhiD/q/UmxeLEfQDNl0bTOziysjGi::2'
Tawk_571f4bb91f16e76c2533f8d7   
'vs25.tawk.to:443::0'
META
Variable    Value
TMP 
'C:\\Users\\Milano\\AppData\\Local\\Temp'
COMPUTERNAME    
'MILWOU_NB'
wsgi.multiprocess   
False
PROCESSOR_LEVEL 
'6'
_OLD_VIRTUAL_PATH   
'C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Python27\\;C:\\Python27\\Scripts;C:\\Python27\\Lib\\site-packages\\PyQt4;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Acer\\abFiles\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files (x86)\\Git\\cmd;C:\\Program Files (x86)\\Windows Live\\Shared;C:\\Program Files\\OpenVPN\\bin;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files (x86)\\MiKTeX 2.9\\miktex\\bin\\;C:\\Program Files\\gettext-iconv;C:\\Program Files\\TortoiseGit\\bin;%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Acer\\abFiles\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Python27\\Scripts\\pip.exe;C:\\Python27\\Scripts;C:\\Program Files (x86)\\HMA! Pro VPN\\bin'
HTTP_REFERER    
'http://127.0.0.1:8000/deliver-job/23'
USERDOMAIN  
'MILWOU_NB'
SERVER_PROTOCOL 
'HTTP/1.1'
SERVER_SOFTWARE 
'WSGIServer/0.1 Python/2.7.10'
PSMODULEPATH    
'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\'
SCRIPT_NAME 
u''
COMMONPROGRAMFILES  
'C:\\Program Files (x86)\\Common Files'
PROCESSOR_IDENTIFIER    
'Intel64 Family 6 Model 60 Stepping 3, GenuineIntel'
REQUEST_METHOD  
'POST'
PROGRAMFILES    
'C:\\Program Files (x86)'
PROCESSOR_REVISION  
'3c03'
PATH    
'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv\\Scripts;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Python27\\;C:\\Python27\\Scripts;C:\\Python27\\Lib\\site-packages\\PyQt4;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Acer\\abFiles\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files (x86)\\Git\\cmd;C:\\Program Files (x86)\\Windows Live\\Shared;C:\\Program Files\\OpenVPN\\bin;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files (x86)\\MiKTeX 2.9\\miktex\\bin\\;C:\\Program Files\\gettext-iconv;C:\\Program Files\\TortoiseGit\\bin;%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Acer\\abFiles\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Python27\\Scripts\\pip.exe;C:\\Python27\\Scripts;C:\\Program Files (x86)\\HMA! Pro VPN\\bin'
QUERY_STRING    
''
SYSTEMROOT  
'C:\\WINDOWS'
HTTP_ORIGIN 
'http://127.0.0.1:8000'
PROGRAMFILES(X86)   
'C:\\Program Files (x86)'
RUN_MAIN    
'true'
CONTENT_LENGTH  
'162574'
HTTP_UPGRADE_INSECURE_REQUESTS  
'1'
VIRTUAL_ENV 
'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\venv'
HTTP_CACHE_CONTROL  
'max-age=0'
HTTP_CONNECTION 
'keep-alive'
HTTP_COOKIE 
'sessionid=v0w7l15uhc4461nfgf8sbnd216qh447e; csrftoken=U9fbDLXpsFlx5duvaxlVns1b0SPMZZ8x; TawkConnectionTime=0; __tawkuuid=e::127.0.0.1::BOXGnOXlC+sZ1MnGIBfHRSpvgi8UQU4rXEVrhiD/q/UmxeLEfQDNl0bTOziysjGi::2; Tawk_571f4bb91f16e76c2533f8d7=vs25.tawk.to:443::0'
TEMP    
'C:\\Users\\Milano\\AppData\\Local\\Temp'
REMOTE_ADDR 
'127.0.0.1'
COMMONPROGRAMFILES(X86) 
'C:\\Program Files (x86)\\Common Files'
PROCESSOR_ARCHITECTURE  
'x86'
wsgi.url_scheme 
'http'
ALLUSERSPROFILE 
'C:\\ProgramData'
SERVER_PORT 
'8000'
LOCALAPPDATA    
'C:\\Users\\Milano\\AppData\\Local'
FPS_BROWSER_USER_PROFILE_STRING 
'Default'
HOMEPATH    
'\\Users\\Milano'
USERDOMAIN_ROAMINGPROFILE   
'MILWOU_NB'
PROGRAMW6432    
'C:\\Program Files'
USERNAME    
'Milano'
HTTP_ACCEPT 
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
LOGONSERVER 
'\\\\MicrosoftAccount'
PROMPT  
'(venv) $P$G'
COMSPEC 
'C:\\WINDOWS\\system32\\cmd.exe'
PROGRAMDATA 
'C:\\ProgramData'
wsgi.multithread    
True
CSRF_COOKIE 
u'U9fbDLXpsFlx5duvaxlVns1b0SPMZZ8x'
FPS_BROWSER_APP_PROFILE_STRING  
'Internet Explorer'
wsgi.input  
<socket._fileobject object at 0x03DB4A30>
HTTP_USER_AGENT 
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
HTTP_HOST   
'127.0.0.1:8000'
SESSIONNAME 
'Console'
PATHEXT 
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
PATH_INFO   
u'/deliver-job/23'
FP_NO_HOST_CHECK    
'NO'
WINDIR  
'C:\\WINDOWS'
wsgi.file_wrapper   
''
HTTP_ACCEPT_ENCODING    
'gzip, deflate'
wsgi.version    
(1, 0)
HOMEDRIVE   
'C:'
APPDATA 
'C:\\Users\\Milano\\AppData\\Roaming'
SERVER_NAME 
'Milwou_NB'
wsgi.run_once   
False
REMOTE_HOST 
''
SYSTEMDRIVE 
'C:'
GATEWAY_INTERFACE   
'CGI/1.1'
HTTP_ACCEPT_LANGUAGE    
'en-US,en;q=0.8'
wsgi.errors 
<open file '<stderr>', mode 'w' at 0x007AD0D0>
NUMBER_OF_PROCESSORS    
'4'
_OLD_VIRTUAL_PROMPT 
'$P$G'
DJANGO_SETTINGS_MODULE  
'SolutionsForLanguages_2.settings'
CONTENT_TYPE    
'multipart/form-data; boundary=----WebKitFormBoundaryOHKWSJuBh6qOgfiS'
PROCESSOR_ARCHITEW6432  
'AMD64'
COMMONPROGRAMW6432  
'C:\\Program Files\\Common Files'
OS  
'Windows_NT'
PUBLIC  
'C:\\Users\\Public'
USERPROFILE 
'C:\\Users\\Milano'
Settings
Using settings module SolutionsForLanguages_2.settings

Setting Value
SECURE_BROWSER_XSS_FILTER   
False
USE_THOUSAND_SEPARATOR  
False
CSRF_COOKIE_SECURE  
False
LANGUAGE_CODE   
'en-us'
ROOT_URLCONF    
'SolutionsForLanguages_2.urls'
MANAGERS    
()
BASE_DIR    
'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2'
SILENCED_SYSTEM_CHECKS  
[]
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] '
SERVER_EMAIL    
'root@localhost'
SECURE_HSTS_SECONDS 
0
STATICFILES_FINDERS 
('django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder')
SESSION_CACHE_ALIAS 
'default'
SESSION_COOKIE_DOMAIN   
None
SESSION_COOKIE_NAME 
'sessionid'
TIME_INPUT_FORMATS  
('%H:%M:%S', '%H:%M:%S.%f', '%H:%M')
SECURE_REDIRECT_EXEMPT  
[]
DATABASES   
{'default': {'ATOMIC_REQUESTS': False,
             'AUTOCOMMIT': True,
             'CONN_MAX_AGE': 0,
             'ENGINE': 'django.db.backends.sqlite3',
             'HOST': '',
             'NAME': 'C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\db.sqlite3',
             'OPTIONS': {},
             'PASSWORD': u'********************',
             'PORT': '',
             'TEST': {'CHARSET': None,
                      'COLLATION': None,
                      'MIRROR': None,
                      'NAME': None},
             'TIME_ZONE': 'UTC',
             'USER': ''}}
EMAIL_SSL_KEYFILE   
u'********************'
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    
('C:\\Users\\Milano\\PycharmProjects\\FutileStudio\\SolutionsForLanguages_2\\locale/',)
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'}}
SESSION_COOKIE_PATH 
'/'
SECURE_CONTENT_TYPE_NOSNIFF 
False
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',
 'django.middleware.security.SecurityMiddleware',
 'django.middleware.locale.LocaleMiddleware')
USE_I18N    
True
THOUSAND_SEPARATOR  
','
SECRET_KEY  
u'********************'
LANGUAGE_COOKIE_NAME    
'django_language'
DEFAULT_INDEX_TABLESPACE    
''
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    
'SolutionsForLanguages_2.wsgi.application'
TEMPLATE_DEBUG  
False
X_FRAME_OPTIONS 
'SAMEORIGIN'
CSRF_COOKIE_NAME    
'csrftoken'
FORCE_SCRIPT_NAME   
None
USE_X_FORWARDED_HOST    
False
EMAIL_TIMEOUT   
None
SECURE_SSL_HOST 
None
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',
 'SolutionsForLanguagesApp',
 'quiz',
 'crispy_forms',
 'super_inlines',
 'django_tables2',
 'essay',
 'multichoice',
 'true_false',
 'smart_selects',
 'django_extensions')
LANGUAGES   
[('en', <django.utils.functional.__proxy__ object at 0x02B1E630>),
 ('fr', <django.utils.functional.__proxy__ object at 0x02B1E710>)]
USE_L10N    
True
SECURE_HSTS_INCLUDE_SUBDOMAINS  
False
STATICFILES_DIRS    
()
PREPEND_WWW 
False
SECURE_PROXY_SSL_HEADER 
None
LANGUAGE_COOKIE_AGE 
None
SESSION_COOKIE_HTTPONLY 
True
DEBUG_PROPAGATE_EXCEPTIONS  
False
CSRF_COOKIE_AGE 
31449600
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   
True
FIXTURE_DIRS    
()
EMAIL_HOST  
'smtp.gmail.com'
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   
()
DISALLOWED_USER_AGENTS  
()
ALLOWED_INCLUDE_ROOTS   
()
LOGGING 
{}
SHORT_DATE_FORMAT   
'm/d/Y'
TEMPLATES   
[{'APP_DIRS': True,
  'BACKEND': 'django.template.backends.django.DjangoTemplates',
  'DIRS': [],
  'OPTIONS': {'context_processors': ['django.template.context_processors.debug',
                                     'django.template.context_processors.request',
                                     'django.contrib.auth.context_processors.auth',
                                     'django.contrib.messages.context_processors.messages',
                                     'django.core.context_processors.i18n']}}]
TEST_RUNNER 
'django.test.runner.DiscoverRunner'
CACHE_MIDDLEWARE_KEY_PREFIX 
u'********************'
SECURE_SSL_REDIRECT 
False
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.template.context_processors.debug',
 'django.template.context_processors.i18n',
 'django.template.context_processors.media',
 'django.template.context_processors.static',
 'django.template.context_processors.tz',
 'django.contrib.messages.context_processors.messages')
SESSION_COOKIE_AGE  
1209600
SETTINGS_MODULE 
'SolutionsForLanguages_2.settings'
USE_ETAGS   
False
LANGUAGES_BIDI  
('he', 'ar', 'fa', 'ur')
FILE_UPLOAD_TEMP_DIR    
None
INTERNAL_IPS    
()
STATIC_URL  
'/static/'
EMAIL_PORT  
587
USE_TZ  
True
SHORT_DATETIME_FORMAT   
'm/d/Y P'
TEST_NON_SERIALIZED_APPS    
[]
PASSWORD_HASHERS    
u'********************'
ABSOLUTE_URL_OVERRIDES  
{}
LANGUAGE_COOKIE_PATH    
'/'
CACHE_MIDDLEWARE_SECONDS    
600
EMAIL_SSL_CERTFILE  
None
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 
'futilestudio@gmail.com'
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 page generated by the handler for this status code.

1 个答案:

答案 0 :(得分:1)

对于notes,您正确地从deliver_form.cleaned_data获取了值。但对于file,您可以直接从deliver_form获取;你也应该在那里使用cleaned_data