Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default length for varchar of the field is insufficient #2

Open
GoogleCodeExporter opened this issue Dec 2, 2015 · 1 comment
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Follow normal steps and try to add a photo

Warning at /admin/clothes/image/add/
Data truncated for column 'photo' at row 1
Request Method: POST
Request URL:    http://shady.akwire.lan:9000/admin/clothes/image/add/
Django Version: 1.4.2
Exception Type: Warning
Exception Value:    
Data truncated for column 'photo' at row 1

The URL it's making (which I see in error log) is 
https://picasaweb.google.com/data/entry/api/user/107481063111315673154/albumid/5
829459793583883265/photoid/5829459798970893554 and the database was created 
with photo field as varchar(100), so 100 is too short.

Request Method: POST
Request URL: http://shady.akwire.lan:9000/admin/clothes/image/add/

Django Version: 1.4.2
Python Version: 2.7.1
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'polls',
 'clothes',
 'django.contrib.admin',
 'south',
 'autocomplete_light',
 'picasa')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/home/dave/google_appengine/lib/django_1_4/django/core/handlers/base.py" 
in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File 
"/home/dave/google_appengine/lib/django_1_4/django/contrib/admin/options.py" in 
wrapper
  366.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/dave/google_appengine/lib/django_1_4/django/utils/decorators.py" in 
_wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File 
"/home/dave/google_appengine/lib/django_1_4/django/views/decorators/cache.py" 
in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/home/dave/google_appengine/lib/django_1_4/django/contrib/admin/sites.py" 
in inner
  196.             return view(request, *args, **kwargs)
File "/home/dave/google_appengine/lib/django_1_4/django/utils/decorators.py" in 
_wrapper
  25.             return bound_func(*args, **kwargs)
File "/home/dave/google_appengine/lib/django_1_4/django/utils/decorators.py" in 
_wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/home/dave/google_appengine/lib/django_1_4/django/utils/decorators.py" in 
bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/home/dave/google_appengine/lib/django_1_4/django/db/transaction.py" in 
inner
  209.                 return func(*args, **kwargs)
File 
"/home/dave/google_appengine/lib/django_1_4/django/contrib/admin/options.py" in 
add_view
  955.                 self.save_model(request, new_object, form, False)
File 
"/home/dave/google_appengine/lib/django_1_4/django/contrib/admin/options.py" in 
save_model
  709.         obj.save()
File "/home/dave/google_appengine/lib/django_1_4/django/db/models/base.py" in 
save
  463.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/dave/google_appengine/lib/django_1_4/django/db/models/base.py" in 
save_base
  551.                 result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/home/dave/google_appengine/lib/django_1_4/django/db/models/manager.py" 
in _insert
  203.         return insert_query(self.model, objs, fields, **kwargs)
File "/home/dave/google_appengine/lib/django_1_4/django/db/models/query.py" in 
insert_query
  1593.     return query.get_compiler(using=using).execute_sql(return_id)
File 
"/home/dave/google_appengine/lib/django_1_4/django/db/models/sql/compiler.py" 
in execute_sql
  910.             cursor.execute(sql, params)
File "/home/dave/google_appengine/lib/django_1_4/django/db/backends/util.py" in 
execute
  40.             return self.cursor.execute(sql, params)
File 
"/home/dave/google_appengine/lib/django_1_4/django/db/backends/mysql/base.py" 
in execute
  114.             return self.cursor.execute(query, args)

Exception Type: Warning at /admin/clothes/image/add/
Exception Value: Data truncated for column 'photo' at row 1



Original issue reported on code.google.com by davemccloskey on 4 Jan 2013 at 5:39

@GoogleCodeExporter
Copy link
Author

Based on this blog post 
http://reinout.vanrees.org/weblog/2012/04/13/django-filefield-limitation.html, 
you can fix this issue by passing max_length argument to PicasaField.

Example:

class Image(models.Model):
  photo = PicasaField(upload_to='/foo', max_length=300)

Original comment by davemccloskey on 4 Jan 2013 at 5:45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant