Simple History - Field Change

148 views
Skip to first unread message

Aaron Reabow

unread,
Jul 4, 2014, 10:49:01 AM7/4/14
to django...@googlegroups.com
Hi all,

I am getting this error on a modelform
smallint out of range


But the form is actually submitting just fine and being stored in the DB.  I used to have a positive small int, but have changed it  (dropped the offending table, resync'ed, restarted the server...)
I have history = HistoricalRecords() as one of the fields  (ie am tracking changes with django-simple-history), and I wonder if this is effecting my ability to make changes to the model.

My other thought is that it is a caching problem somewhere.

has anyone come across this problem and have any idea how to fix?

many thanks,

Aaron

Cal Leeming [Simplicity Media Ltd]

unread,
Jul 4, 2014, 11:43:50 AM7/4/14
to django...@googlegroups.com
Can you please paste the full clear text stacktrace?

Cal


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6af23e8d-9f15-477d-843f-dc9c33b7edf9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Reabow

unread,
Jul 4, 2014, 11:47:34 AM7/4/14
to django...@googlegroups.com
Environment:


Request Method: POST
Request URL: upon request :)

Django Version: 1.6.2
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.auth',
 'django.contrib.sites',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'myproject.ngc',
 'registration',
 'crispy_forms',
 'floppyforms',
 'simple_history')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/core/handlers/base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/metadata/webapps/greenhouse/myproject/myproject/ngc/views.py" in leadManagementView
  540.             model_instance.save()
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/base.py" in save
  545.                        force_update=force_update, update_fields=update_fields)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/base.py" in save_base
  582.                                    update_fields=update_fields, raw=raw, using=using)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/dispatch/dispatcher.py" in send
  185.             response = receiver(signal=self, sender=sender, **named)
File "/home/metadata/.local/lib/python2.7/site-packages/simple_history/models.py" in post_save
  209.             self.create_historical_record(instance, created and '+' or '~')
File "/home/metadata/.local/lib/python2.7/site-packages/simple_history/models.py" in create_historical_record
  222.                        history_user=history_user, **attrs)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/manager.py" in create
  157.         return self.get_queryset().create(**kwargs)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/query.py" in create
  319.         obj.save(force_insert=True, using=self.db)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/base.py" in save
  545.                        force_update=force_update, update_fields=update_fields)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/base.py" in save_base
  573.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/base.py" in _save_table
  654.             result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/base.py" in _do_insert
  687.                                using=using, raw=raw)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/manager.py" in _insert
  232.         return insert_query(self.model, objs, fields, **kwargs)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/query.py" in insert_query
  1511.     return query.get_compiler(using=using).execute_sql(return_id)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/models/sql/compiler.py" in execute_sql
  899.             cursor.execute(sql, params)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/backends/util.py" in execute
  69.             return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/backends/util.py" in execute
  53.                 return self.cursor.execute(sql, params)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/utils.py" in __exit__
  99.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/metadata/webapps/greenhouse/lib/python2.7/django/db/backends/util.py" in execute
  53.                 return self.cursor.execute(sql, params)

Exception Type: DataError at /leads
Exception Value: smallint out of range

Cal Leeming [Simplicity Media Ltd]

unread,
Jul 4, 2014, 12:05:43 PM7/4/14
to django...@googlegroups.com
It sounds like you haven't applied the table changes to the cloned table which it creates to track changes.

I'd advice using something like South to manage your schema changes, and this should work out of the box with django-simple-history. 

For now, you can delete the cloned table and re-sync, you will naturally lose the historical data but if you deleted the original then this probably won't matter.

It's also worth mentioning that the design approach of django-simple-history is completely wrong, and personally I wouldn't recommend using it. Feel free to start a separate thread if you'd like to discuss that further though as it's slightly off topic for this thread.

Let us know how you get on.

Cal


Aaron Reabow

unread,
Jul 5, 2014, 1:32:55 AM7/5/14
to django...@googlegroups.com
You are totally right.

There is a historical table that required deletion.

This is why you shouldn't debug late on friday afternoon.  I had actually looked for that table but somehow missed it.

I will pick up the broader problems with simple history separately.

thanks for taking the time to look through this Cal. 

Cal Leeming [Simplicity Media Ltd]

unread,
Jul 5, 2014, 10:14:12 AM7/5/14
to django...@googlegroups.com
No problem at all, glad you got it sorted!

Cal


Reply all
Reply to author
Forward
0 new messages