Django錯誤'unicode'對象沒有屬性'name'

[英]Django error 'unicode' object has no attribute 'name'


LS,

I'm trying to build a website for a study association, using the Django cms and on top of that mezzanine.

我正在嘗試為一個研究協會建立一個網站,使用Django cms並在該夾層之上。

When I try to upload a .zip file into the gallery page (supported by the mezzanine.galleries) a certain error is raised (the traceback is posted below).

當我嘗試將.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'

It seems as if though this is a more general problem than just with uploading a zip, as it has occurred more times (for example, when I run the command python manage.py createdb)

好像雖然這是一個比上傳zip更常見的問題,因為它已經發生了很多次(例如,當我運行命令python manage.py createdb時)

Sadly I haven't found a solution which helps me yet.

可悲的是,我還沒有找到幫助我的解決方案。

Thanks in advance

提前致謝

1 个解决方案

#1


0  

I think this link will be able to help you out:

我認為此鏈接可以幫助您:

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

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/03/08/f291f3b65e2138f738d5071eeb1ce750.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com