Django错误'unicode'对象没有属性'name'

时间:2016-03-08 21:38:51

标签: python django mezzanine

LS,

我正在尝试为一个研究协会建立一个网站,使用Django cms并在该夹层之上。

当我尝试将.zip文件上传到图库页面时(由mezzanine.galleries支持)会引发某个错误(回溯在下面发布)。

Environment:


Request Method: POST
Request URL: *mysite*/admin/galleries/gallery/add/

Django Version: 1.8.4
Python Version: 2.7.6
Installed Applications:
(u'mezzanine.boot',
u'django.contrib.auth',
u'django.contrib.contenttypes',
u'django.contrib.redirects',
u'django.contrib.sessions',
u'django.contrib.sites',
u'django.contrib.sitemaps',
u'mezzanine.conf',
u'mezzanine.core',
u'mezzanine.generic',
u'mezzanine.pages',
u'mezzanine.blog',
u'mezzanine.forms',
u'mezzanine.galleries',
u'mezzanine.twitter',
u'mezzanine_bsbanners',
u'mezzanine_file_collections',
u'mezzanine.accounts',
u'theme',
u'commissiepage',
u'filebrowser_safe',
u'grappelli_safe',
u'django.contrib.admin',
u'django.contrib.staticfiles',
u'django_comments')
Installed Middleware:
(u'django.contrib.sessions.middleware.SessionMiddleware',
u'django.middleware.common.CommonMiddleware',
u'django.middleware.csrf.CsrfViewMiddleware',
u'django.contrib.auth.middleware.AuthenticationMiddleware',
u'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
u'django.contrib.messages.middleware.MessageMiddleware',
u'django.middleware.clickjacking.XFrameOptionsMiddleware',
u'mezzanine.core.request.CurrentRequestMiddleware',
u'mezzanine.core.middleware.RedirectFallbackMiddleware',
u'mezzanine.core.middleware.TemplateForDeviceMiddleware',
u'mezzanine.core.middleware.TemplateForHostMiddleware',
u'mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware',
u'mezzanine.core.middleware.SitePermissionMiddleware',
u'mezzanine.pages.middleware.PageMiddleware')


Traceback:  
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/djang/core/handlers/base.py" in get_response 132.
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper 616.
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 110.
response = view_func(request, *args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57.
response = view_func(request, *args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner 233.             
return view(request, *args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/pages/admin.py" in add_view 104.         
return super(PageAdmin, self).add_view(request, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view 1516.        
return self.changeform_view(request, None, form_url, extra_context)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper 34.             
return bound_func(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 110.                     
response = view_func(request, *args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func 30.                 
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/utils/decorators.py" in inner 145.                     
return func(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view 1467.
self.save_model(request, new_object, form, not add)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/pages/admin.py" in save_model 164.         
super(PageAdmin, self).save_model(request, obj, form, change)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/core/admin.py" in save_model 104.         
super(DisplayableAdmin, self).save_model(request, obj, form, change)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/contrib/admin/options.py" in save_model 1078.         
obj.save()
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/page/models.py" in save 87.         
super(Page, self).save(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/core/models.py" in save 437.         
super(Orderable, self).save(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/core/models.py" in save 252.         
super(Displayable, self).save(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/core/models.py" in save 85.         
super(Slugged, self).save(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/core/models.py" in save 58.         
super(SiteRelated, self).save(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/core/models.py" in save 142.         
super(MetaData, self).save(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/core/models.py" in save 205.         
super(TimeStamped, self).save(*args, **kwargs)
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/galleries/models.py" in save 100.       
self.images.add(GalleryImage(file=saved_path))
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/django/db/models/fields/related.py" in add 746.                     
obj.save()
File "/var/www/nsaweb/venv/lib/python2.7/site-packages/mezzanine/galleries/models.py" in save 138.             
name = force_text(self.file.name)

Exception Type: AttributeError at /admin/galleries/gallery/add/
Exception Value: 'unicode' object has no attribute 'name'

似乎虽然这是一个更普遍的问题,而不仅仅是上传一个zip,因为它发生了更多次(例如,当我运行命令python manage.py createdb)

可悲的是,我还没有找到帮助我的解决方案。

提前致谢

1 个答案:

答案 0 :(得分:0)

我认为此链接可以帮助您:

http://stackoverflow.com/questions/14826183/django-error-unicode-object-has-no-attribute-objects