Save model by code then OK. But I can't save model in admin. See error
below:
TypeError at /admin/food/food/2/
expected string or buffer
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/food/food/2/
Django Version: 1.8.3
Exception Type: TypeError
Exception Value:
expected string or buffer
Exception Location: C:\Python27\Lib\json\decoder.py in decode, line
365
Python Executable: D:\Program
Files\PythonEnv\foodgreen\Scripts\python.exe
Python Version: 2.7.6
Python Path:
['D:\\Projects\\Django8\\greenfood',
'D:\\Program
Files\\eclipse\\plugins\\org.python.pydev_4.2.0.201507041133\\pysrc',
'D:\\Projects\\Django8\\greenfood',
'D:\\Program Files\\PythonEnv\\foodgreen\\lib\\site-
packages\\psycopg2-2.6.1-py2.7-win32.egg',
'D:\\Program Files\\PythonEnv\\foodgreen\\lib',
'D:\\Program Files\\PythonEnv\\foodgreen\\Scripts',
'C:\\Python27\\Lib',
'C:\\Python27\\DLLs',
'C:\\Python27\\Lib\\lib-tk',
'D:\\Program Files\\PythonEnv\\foodgreen',
'D:\\Program Files\\PythonEnv\\foodgreen\\lib\\site-packages',
'C:\\WINDOWS\\SYSTEM32\\python27.zip',
'D:\\Program Files\\PythonEnv\\foodgreen\\DLLs',
'D:\\Program Files\\PythonEnv\\foodgreen\\lib\\plat-win',
'D:\\Program Files\\PythonEnv\\foodgreen\\lib\\lib-tk']
Server time: Thu, 6 Aug 2015 16:48:26 +0700
Traceback Switch to copy-and-paste view
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\core\handlers\base.py in get_response
response = wrapped_callback(request,
*callback_args, **callback_kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\contrib\admin\options.py in wrapper
return self.admin_site.admin_view(view)(*args,
**kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\utils\decorators.py in _wrapped_view
response = view_func(request, *args,
**kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\views\decorators\cache.py in _wrapped_view_func
response = view_func(request, *args, **kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\contrib\admin\sites.py in inner
return view(request, *args, **kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\contrib\admin\options.py in change_view
return self.changeform_view(request, object_id,
form_url, extra_context) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\utils\decorators.py in _wrapper
return bound_func(*args, **kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\utils\decorators.py in _wrapped_view
response = view_func(request, *args,
**kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\utils\decorators.py in bound_func
return func.__get__(self, type(self))(*args2,
**kwargs2) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\utils\decorators.py in inner
return func(*args, **kwargs) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\contrib\admin\options.py in changeform_view
change_message =
self.construct_change_message(request, form, formsets) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\contrib\admin\options.py in construct_change_message
if form.changed_data: ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\forms\forms.py in changed_data
if field.has_changed(initial_value,
data_value): ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\contrib\postgres\forms\hstore.py in has_changed
initial_value = self.to_python(initial) ...
▶ Local vars
D:\Program Files\PythonEnv\foodgreen\lib\site-
packages\django\contrib\postgres\forms\hstore.py in to_python
value = json.loads(value) ...
▶ Local vars
C:\Python27\Lib\json\__init__.py in loads
return _default_decoder.decode(s) ...
▶ Local vars
C:\Python27\Lib\json\decoder.py in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ...
▶ Local vars
Request information
GET
No GET data
POST
Variable Value
rate_count
u'0'
code
u'P000002'
foodimage_set-1-description
u''
weight
u'{"1.5": "1.1kg - 2kg", "0.5": "0.5kg - 1kg"}'
photo
u''
rate
u'4'
foodimage_set-0-description
u''
foodimage_set-0-ordering
u'0'
foodimage_set-0-food
u'2'
foodimage_set-TOTAL_FORMS
u'2'
unit
u'con,kg'
description
u'<div><div>Chi ti\u1ebft s\u1ea3n ph\u1ea9m Th\u1ecbt g\xe0
s\u1ea1ch</div><div><br></div><div>Ch\xfang ta th\u01b0\u1eddng nghe
\u0111\u1ebfn rau qu\u1ea3 s\u1ea1ch, tr\u1ee9ng s\u1ea1ch..., nh\u01b0ng
l\u1ea1i qu\xean r\u1eb1ng th\u1ecbt c\u0169ng c\xf3 th\u1ec3
\u0111\u01b0\u1ee3c l\u1ea5y t\u1eeb gia s\xfac nu\xf4i b\u1eb1ng
th\u1ee9c \u0103n th\u1ef1c v\u1eadt \u201csinh h\u1ecdc\u201d... v\u1edbi
m\u1ed9t quy tr\xecnh ph\xf9 h\u1ee3p v\u1edbi t\u1ef1 nhi\xean. Th\u1ecbt
\u0111\xf3 ch\xednh l\xe0 \u201cth\u1ecbt s\u1ea1ch\u201d. N\xf3i
\u0111\u01a1n gi\u1ea3n h\u01a1n, th\u1ecbt s\u1ea1ch l\xe0 s\u1ea3n
ph\u1ea9m kh\xf4ng c\xf3 thu\u1ed1c, kh\xe1ng sinh, hormon, ch\u1ea5t
k\xedch th\xedch t\u0103ng tr\u01b0\u1edfng... Gia s\xfac ch\u1ec9 \u0103n
c\u1ecf r\u01a1m hay ng\u0169 c\u1ed1c c\xf3 ch\u1ee9ng nh\u1eadn sinh
h\u1ecdc kh\xf4ng thu\u1ed1c tr\u1eeb s\xe2u hay ph\xe2n b\xf3n h\xf3a
h\u1ecdc.</div><div><br></div><div>C\xf3 th\u1ec3 th\u1ea5y, th\u1ecbt
s\u1ea1ch t\u1eeb qu\xe1 tr\xecnh \u201cch\u0103n nu\xf4i s\u1ea1ch\u201d
c\xf3 l\u1ee3i v\xe0 an to\xe0n h\u01a1n cho s\u1ee9c kh\u1ecfe. M\u1ed9t
l\u1ee3i \xedch kh\xe1c khi ti\xeau thu th\u1ecbt s\u1ea1ch - l\xe0 g\xf3p
ph\u1ea7n v\xe0o s\u1ef1 ph\xe1t tri\u1ec3n c\u1ee7a m\u1ed9t n\u1ec1n
n\xf4ng nghi\u1ec7p b\u1ec1n v\u1eefng, t\xf4n tr\u1ecdng m\xf4i
tr\u01b0\u1eddng v\xe0 ph\xf9 h\u1ee3p v\u1edbi thi\xean
nhi\xean.</div><div><br></div><div><br></div><div>\u0110\u1eb6C
\u0110I\u1ec2M N\u1ed4I B\u1eacT</div><div><br></div><div>Ch\u1ee9ng
nh\u1eadn ti\xeau chu\u1ea9n s\u1ea3n ph\u1ea9m 246 / 2009 / YT\u0110N
\u2013 CNTC.</div><div><br></div><div>S\u1ea3n ph\u1ea9m ch\u1ebf
bi\u1ebfn ra \u0111\u01b0\u1ee3c b\u1ea3o qu\u1ea3n trong kho l\u1ea1nh
tr\u01b0\u1edbc khi v\u1eadn chuy\u1ec3n t\u1edbi kh\xe1ch h\xe0ng.
V\u1edbi h\u1ec7 th\u1ed1ng xe l\u1ea1nh chuy\xean d\u1ee5ng
b\u1ea3o qu\u1ea3n s\u1ea3n ph\u1ea9m t\u1edbi kh\xe1ch
h\xe0ng</div><div><br></div><div>S\u1ea3n ph\u1ea9m th\u1ecbt g\xe0
s\u1ea1ch \u0111\u01b0\u1ee3c cung c\u1ea5p cho th\u1ecb tr\u01b0\u1eddng
TP.HCM v\xe0 c\xe1c h\u1ec7 th\u1ed1ng si\xeau th\u1ecb tr\xean to\xe0n
qu\u1ed1c.</div><div><br></div><div>\u0110\u1ebfn v\u1edbi Green Healthy
c\xe1c b\u1ea1n c\xf3 th\u1ec3 mua \u0111\u01b0\u1ee3c r\u1ea5t nhi\u1ec1u
c\xe1c s\u1ea3n ph\u1ea9m t\u1eeb th\u1ecbt g\xe0 c\xf4ng nghi\u1ec7p
th\u1ea3 v\u01b0\u1eddn nh\u01b0: g\xe0 nguy\xean con, c\xe1nh g\xe0
nguy\xean, g\xe0 g\xf3c t\u01b0, \u0111\xf9i g\xe0 t\u1ecfi, \u1ee9c g\xe0
phi l\xea, l\xf2ng g\xe0 v\u1edbi gi\xe1 c\u1ea3 r\u1ea5t kinh
t\u1ebf.</div><div><br></div><div>B\u1eadt m\xed l\xe0 khi ch\u1ebf
bi\u1ebfn m\xf3n \u0103n t\u1eeb th\u1ecbt g\xe0, s\u1eed d\u1ee5ng
c\xf9ng lo\u1ea1i th\u1ecbt nh\u01b0 c\xe1nh, \u0111\xf9i s\u1ebd
khi\u1ebfn cho m\xf3n \u0103n tr\xf4ng h\u1ea5p d\u1eabn nhi\u1ec1u so
v\u1edbi khi ch\xfang ta d\xf9ng nhi\u1ec1u ph\u1ea7n th\u1ecbt tr\xean
m\u1ed9t con g\xe0. </div></div><div><br></div>'
category
u'9'
view_count
u'0'
knowledge
u'Th\u1ecbt g\xe0 ch\u1ee9a nhi\u1ec1u \u0111\u1ea1m r\u1ea5t
t\u1ed1t cho con ng\u01b0\u1eddi '
foodimage_set-1-id
u''
storage
u'Tr\u1eed l\u1ea1nh nguy\xean con.'
unit_price
u'kg'
foodimage_set-1-image
u''
csrfmiddlewaretoken
u'kulTr1CR3Co8Y5Q0HHgsgdeaY7jdtFPe'
foodimage_set-0-image
u''
foodimage_set-MAX_NUM_FORMS
u'1000'
files
u''
foodimage_set-1-title
u''
_save
u'Save'
price
u'200000'
discount
u'0'
active
u'on'
foodimage_set-0-id
u'1'
foodimage_set-__prefix__-id
u''
foodimage_set-1-food
u'2'
foodimage_set-1-ordering
u'0'
name
u'G\xe0 ta'
foodimage_set-__prefix__-image
u''
price_markup
u'0'
made_in
u'<p style="transition: all 0.25s ease-in-out; margin: 0px; padding-top:
0px; padding-bottom: 0px; border: 0px; font-family: inherit; font-size:
inherit; font-style: inherit; font-variant: inherit; font-weight: inherit;
font-stretch: inherit; line-height: 23px;">Ngu\u1ed3n g\u1ed1c h\xe0ng:
ch\u1ee3 \u0111\u1ea7u m\u1ed1i</p>'
foodimage_set-__prefix__-description
u''
foodimage_set-MIN_NUM_FORMS
u'0'
foodimage_set-__prefix__-title
u''
foodimage_set-0-title
u'S\u01a1 ch\u1ebf nguy\xean tr\u1ea1ng'
foodimage_set-__prefix__-ordering
u'0'
foodimage_set-__prefix__-food
u'2'
foodimage_set-INITIAL_FORMS
u'1'
FILES
No FILES data
COOKIES
Variable Value
__utmz
'96992031.1431488848.165.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)'
uprofile_id
'814f3875-63d9-4cc6-3c8c-6147472a2acf'
__zlcmid
'UieeDPr0v8RGeL'
_ga
'GA1.1.1568320006.1402976746'
_hjIncludedInSample
'1'
__utmv
'96992031.|1=username=hongphi=1'
djdttop
'469'
djdt
'hide'
csrftoken
'kulTr1CR3Co8Y5Q0HHgsgdeaY7jdtFPe'
__utma
'96992031.1568320006.1402976746.1438407126.1438609717.338'
__utmc
'96992031'
sessionid
'hf1rj9fkzit5ududgtnelo6vesp3shqd'
_hjUserId
'8e3fba97-93ad-441f-93f3-1a40d5be285f'
META
Variable Value
HTTP_REFERER
'http://127.0.0.1:8000/admin/food/food/2/'
SERVER_SOFTWARE
'WSGIServer/0.1 Python/2.7.6'
SCRIPT_NAME
u''
REQUEST_METHOD
'POST'
HTTP_ORIGIN
'http://127.0.0.1:8000'
SERVER_PROTOCOL
'HTTP/1.1'
SYSTEMROOT
'C:\\WINDOWS'
CONTENT_LENGTH
'7883'
PYDEV_CONSOLE_ENCODING
'UTF-8'
JAVA_HOME
'C:\\Program Files\\Java\\jdk1.7.0_60'
COMSPEC
'C:\\WINDOWS\\system32\\cmd.exe'
PYTHONPATH
'D:\\Program
Files\\eclipse\\plugins\\org.python.pydev_4.2.0.201507041133\\pysrc\\pydev_sitecustomize;D:\\Projects\\Django8\\greenfood;D:\\Program
Files\\PythonEnv\\foodgreen\\lib\\site-
packages\\psycopg2-2.6.1-py2.7-win32.egg;D:\\Program
Files\\PythonEnv\\foodgreen\\lib;D:\\Program
Files\\PythonEnv\\foodgreen\\Scripts;C:\\Python27\\Lib;C:\\Python27\\DLLs;C:\\Python27\\Lib
\\lib-tk;D:\\Program Files\\PythonEnv\\foodgreen;D:\\Program
Files\\PythonEnv\\foodgreen\\lib\\site-packages'
HTTP_UPGRADE_INSECURE_REQUESTS
'1'
HTTP_CACHE_CONTROL
'max-age=0'
SESSIONNAME
'Console'
HTTP_ACCEPT
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
wsgi.version
(1, 0)
MOZ_PLUGIN_PATH
'C:\\Program Files (x86)\\Foxit Software\\Foxit Reader\\plugins\\'
HOMEDRIVE
'C:'
SYSTEMDRIVE
'C:'
wsgi.multiprocess
False
PROCESSOR_LEVEL
'6'
PUSHER_URL
'http://f79c49fc3872b1ca9f12:8e3fb3ab80...@api.pusherapp.com/apps/88699'
OS
'Windows_NT'
HTTP_COOKIE
'uprofile_id=814f3875-63d9-4cc6-3c8c-6147472a2acf; djdt=hide; djdttop=469;
_hjIncludedInSample=1; _hjUserId=8e3fba97-93ad-441f-93f3-1a40d5be285f;
__zlcmid=UieeDPr0v8RGeL;
__utma=96992031.1568320006.1402976746.1438407126.1438609717.338;
__utmc=96992031;
__utmz=96992031.1431488848.165.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
__utmv=96992031.|1=username=hongphi=1; _ga=GA1.1.1568320006.1402976746;
sessionid=hf1rj9fkzit5ududgtnelo6vesp3shqd;
csrftoken=kulTr1CR3Co8Y5Q0HHgsgdeaY7jdtFPe'
PATH_INFO
u'/admin/food/food/2/'
QUERY_STRING
''
PYTHONUNBUFFERED
'1'
HTTP_USER_AGENT
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/44.0.2403.125 Safari/537.36'
HTTP_CONNECTION
'keep-alive'
TEMP
'C:\\Users\\hongphi\\AppData\\Local\\Temp'
REMOTE_ADDR
'127.0.0.1'
COMMONPROGRAMFILES(X86)
'C:\\Program Files (x86)\\Common Files'
wsgi.url_scheme
'http'
HOMEPATH
'\\Users\\hongphi'
LOGONSERVER
'\\\\MicrosoftAccount'
wsgi.multithread
True
ASL.LOG
'Destination=file'
APPDATA
'C:\\Users\\hongphi\\AppData\\Roaming'
DJANGO_SETTINGS_MODULE
'greenfood.settings'
wsgi.file_wrapper
''
CSRF_COOKIE
u'kulTr1CR3Co8Y5Q0HHgsgdeaY7jdtFPe'
HTTP_ACCEPT_ENCODING
'gzip, deflate'
TMP
'C:\\Users\\hongphi\\AppData\\Local\\Temp'
COMPUTERNAME
'DJANGO-PC'
USERDOMAIN
'DJANGO-PC'
COMMONPROGRAMFILES
'C:\\Program Files (x86)\\Common Files'
HOME
'C:\\Users\\hongphi'
PROCESSOR_ARCHITECTURE
'x86'
ALLUSERSPROFILE
'C:\\ProgramData'
SERVER_PORT
'8000'
USERDOMAIN_ROAMINGPROFILE
'DJANGO-PC'
PROGRAMW6432
'C:\\Program Files'
USERNAME
'hongphi'
PG_CONFIG
'C:\\Program Files\\PostgreSQL\\9.4\\bin'
PROMPT
'$P$G'
HTTP_HOST
'127.0.0.1:8000'
PATHEXT
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
WINDIR
'C:\\WINDOWS'
wsgi.run_once
False
wsgi.errors
<open file '<stderr>', mode 'w' at 0x01DC60D0>
HTTP_ACCEPT_LANGUAGE
'en,vi;q=0.8'
NUMBER_OF_PROCESSORS
'8'
PROCESSOR_ARCHITEW6432
'AMD64'
PUBLIC
'C:\\Users\\Public'
USERPROFILE
'C:\\Users\\hongphi'
PYTHONIOENCODING
'UTF-8'
PSMODULEPATH
'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\'
PROCESSOR_IDENTIFIER
'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'
PROGRAMFILES
'C:\\Program Files (x86)'
PROCESSOR_REVISION
'3a09'
PATH
'C:/Program Files/Java/jre1.8.0_45/bin/server;C:/Program
Files/Java/jre1.8.0_45/bin;C:/Program
Files/Java/jre1.8.0_45/lib/amd64;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program
Files (x86)\\Heroku\\bin;C:\\Program Files
(x86)\\ruby-1.9.2\\bin;C:\\Program Files (x86)\\git\\bin;C:\\Program Files
(x86)\\git\\cmd;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\Program Files
(x86)\\Git\\cmd;C:\\Python27;C:\\Python27\\Scripts;D:\\Program Files
\\gettext-tools\\bin;;D:\\Program Files\\eclipse;'
PROGRAMFILES(X86)
'C:\\Program Files (x86)'
TERM
'emacs'
SERVER_NAME
'tonec.com'
LOCALAPPDATA
'C:\\Users\\hongphi\\AppData\\Local'
PROGRAMDATA
'C:\\ProgramData'
wsgi.input
<socket._fileobject object at 0x03CE8DB0>
FP_NO_HOST_CHECK
'NO'
GATEWAY_INTERFACE
'CGI/1.1'
REMOTE_HOST
''
PYDEV_COMPLETER_PYTHONPATH
'D:\\Program
Files\\eclipse\\plugins\\org.python.pydev_4.2.0.201507041133\\pysrc'
HEROKUPATH
'C:\\Program Files (x86)\\Heroku'
CONTENT_TYPE
'multipart/form-data; boundary=----WebKitFormBoundaryyATMZkszlnEOpBL6'
COMMONPROGRAMW6432
'C:\\Program Files\\Common Files'
ENV_DEV
'1'
Settings
Using settings module greenfood.settings
Setting Value
SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS
['username', 'first_name', 'email']
SECURE_BROWSER_XSS_FILTER
False
USE_THOUSAND_SEPARATOR
False
CSRF_COOKIE_SECURE
False
LANGUAGE_CODE
'en-us'
ROOT_URLCONF
'greenfood.urls'
MANAGERS
()
BASE_DIR
'D:\\Projects\\Django8\\greenfood'
SILENCED_SYSTEM_CHECKS
[]
DEFAULT_CHARSET
'utf-8'
SESSION_SERIALIZER
'django.contrib.sessions.serializers.JSONSerializer'
STATIC_ROOT
'/static/'
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.postgresql_psycopg2',
'HOST': 'localhost',
'NAME': 'green',
'OPTIONS': {},
'PASSWORD': u'********************',
'PORT': '5432',
'TEST': {'CHARSET': None,
'COLLATION': None,
'MIRROR': None,
'NAME': None},
'TIME_ZONE': 'UTC',
'USER': 'postgres'}}
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
FIRST_DAY_OF_WEEK
0
DATABASE_ROUTERS
[]
DEFAULT_TABLESPACE
''
YEAR_MONTH_FORMAT
'F Y'
STATICFILES_STORAGE
'django.contrib.staticfiles.storage.StaticFilesStorage'
CACHES
{'default': {'BACKEND':
'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/var/tmp/django_cache',
'OPTIONS': {'MAX_ENTRIES': 3000}}}
SESSION_COOKIE_PATH
'/'
USE_X_FORWARDED_HOST
False
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.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
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')
WSGI_APPLICATION
'greenfood.wsgi.application'
TEMPLATE_DEBUG
False
X_FRAME_OPTIONS
'SAMEORIGIN'
CSRF_COOKIE_NAME
'csrftoken'
FORCE_SCRIPT_NAME
None
AWS_S3_URL_PROTOCOL
'http:'
AWS_S3_SECURE_URLS
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.sites',
'django.contrib.staticfiles',
'django.contrib.humanize',
'social.apps.django_app.default',
'django.contrib.postgres',
'django.contrib.flatpages',
'food',
'user_profile',
'django_summernote',
'easy_thumbnails',
'easy_thumbnails.optimize',
'reversion')
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'))
USE_L10N
True
SECURE_HSTS_INCLUDE_SUBDOMAINS
False
STATICFILES_DIRS
('D:\\Projects\\Django8\\greenfood\\greenfood/static/',)
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
('social.backends.open_id.OpenIdAuth',
'social.backends.google.GoogleOpenId',
'social.backends.google.GoogleOAuth2',
'social.backends.google.GoogleOAuth',
'social.backends.facebook.FacebookOAuth2',
'django.contrib.auth.backends.ModelBackend')
EMAIL_HOST_PASSWORD
u'********************'
SUMMERNOTE_CONFIG
{'height': 300,
'iframe': False,
'lang': 'vi',
'prettifyHtml': True,
'width': 950}
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
'/'
DECIMAL_SEPARATOR
'.'
IGNORABLE_404_URLS
()
LOCALE_PATHS
()
TEMPLATE_STRING_IF_INVALID
''
LOGOUT_URL
'/accounts/logout/'
EMAIL_USE_TLS
False
FIXTURE_DIRS
()
EMAIL_HOST
'localhost'
DATE_FORMAT
'N j, Y'
MEDIA_ROOT
'D:\\Projects\\Django8\\greenfood\\media'
DEFAULT_EXCEPTION_REPORTER_FILTER
'django.views.debug.SafeExceptionReporterFilter'
ADMINS
()
FORMAT_MODULE_PATH
None
DEFAULT_FROM_EMAIL
'webmaster@localhost'
MEDIA_URL
'/media/'
DATETIME_FORMAT
'N j, Y, P'
TEMPLATE_DIRS
()
SITE_ID
1
DISALLOWED_USER_AGENTS
()
ALLOWED_INCLUDE_ROOTS
()
LOGGING
{}
SHORT_DATE_FORMAT
'm/d/Y'
TEMPLATES
[{'APP_DIRS': True,
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['D:\\Projects\\Django8\\greenfood\\greenfood/templates',
'D:\\Projects\\Django8\\greenfood\\food/templates',
'D:\\Projects\\Django8\\greenfood\\user_profile/templates'],
'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']}}]
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.console.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',
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect')
IS_LOCAL
True
MIGRATION_MODULES
{}
SESSION_COOKIE_AGE
1209600
SETTINGS_MODULE
'greenfood.settings'
USE_ETAGS
False
LANGUAGES_BIDI
('he', 'ar', 'fa', 'ur')
FILE_UPLOAD_TEMP_DIR
None
INTERNAL_IPS
()
STATIC_URL
'/static/'
EMAIL_PORT
25
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
''
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/25233>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> 93f3-1a40d5be285f; __zlcmid=UieeDPr0v8RGeL;
New description:
{{{
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
JSON requires double quotes for strings. I don't think we should strive to
make things work if you manually save invalid data to the field.
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:2>
* status: closed => new
* resolution: invalid =>
Comment:
I see this same error in the Admin even when entering valid data with
double quotes, using Django 1.8.3 and Python 2.7.10:
{{{
patient = Patient.objects.create(user=user, gender="male",
mobile_telecom="555-555-4456",
emergency_contacts={"urgent_care":"555-555-5555"}, utc_offset=0,
birthdate=datetime.datetime.now())
}}}
Returning emergency_contacts from the shell results in single quoted data:
{{{
In [21]: patient.emergency_contacts
Out[21]: {'urgent_care': '6467702435'}
}}}
From the traceback, it seems django's changed_data in forms.py is
transforming the double-quoted data to single-quoted data:
{{{
/lib/python2.7/site-packages/django/forms/forms.py in changed_data
try:
initial_value =
field.to_python(hidden_widget.value_from_datadict(
self.data, self.files,
initial_prefixed_name))
except ValidationError:
# Always assume data has changed if validation
fails.
self._changed_data.append(name)
continue
if field.has_changed(initial_value,
data_value):
...
self._changed_data.append(name)
return self._changed_data
@property
def media(self):
"""
▼ Local vars
Variable Value
data_value
u'{"urgent_care": "555-555-5555"}'
name
'emergency_contacts'
initial_value
{u'urgent_care': u'555-555-5555'}
self
<PatientForm bound=True, valid=True,
fields=(user;gender;birthdate;mobile_telecom;emergency_contacts;utc_offset;hipaa_authorization_timestamp)>
field
<django.contrib.postgres.forms.hstore.HStoreField object at 0x105d54450>
prefixed_name
'emergency_contacts'
}}}
This is using the following model:
{{{
class Patient(TimeStampedModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
user = models.OneToOneField(settings.AUTH_USER_MODEL)
gender = models.CharField(max_length=10, choices=GENDER_CHOICES)
birthdate = models.DateField()
mobile_telecom = PhoneNumberField(unique=True)
emergency_contacts = HStoreField(default={"urgent_care": ""})
utc_offset = models.IntegerField(default=0)
hipaa_authorization_timestamp = models.DateTimeField(null=True,
blank=True)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:3>
* owner: => timgraham
* status: new => assigned
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:4>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/5115 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a7b7f27c05244d69a11545261eb3bbd73791b3d2" a7b7f27c]:
{{{
#!CommitTicketReference repository=""
revision="a7b7f27c05244d69a11545261eb3bbd73791b3d2"
Fixed #25233 -- Fixed HStoreField.has_changed() handling of initial
values.
Thanks Simon Charette for review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"ad2ac53054f1deea6818d05220db73f6c09c1702" ad2ac53]:
{{{
#!CommitTicketReference repository=""
revision="ad2ac53054f1deea6818d05220db73f6c09c1702"
[1.8.x] Fixed #25233 -- Fixed HStoreField.has_changed() handling of
initial values.
Thanks Simon Charette for review.
Backport of a7b7f27c05244d69a11545261eb3bbd73791b3d2 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25233#comment:8>