WilliamRen / django-pyodbc

Automatically exported from code.google.com/p/django-pyodbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Proxy of User model fails on admin interface #84

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I'm using this class:

    class OrderedUser(User):
        def __unicode__(self):
            return self.get_full_name()

        class Meta:
            proxy = True
            ordering = ["first_name", "last_name",]

2. The admin interface fails with "[42S22] [FreeTDS][SQL Server]Invalid column 
name 
'ordereduser_id'. (207) (SQLPrepare)" when I try to save a new instance that 
has a OrderedUser 
field.

What version of the product are you using? On what operating system?
Django 1.2.1, Django PyODBC rev.182, SQL Server 2005 SP3

Please provide any additional information below.

Traceback:
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/contrib/admin/options.py" in wrapper
  239.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/utils/decorators.py" in _wrapped_view
  76.                     response = view_func(request, *args, **kwargs)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/views/decorators/cache.py" in _wrapped_view_func
  69.         response = view_func(request, *args, **kwargs)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/contrib/admin/sites.py" in inner
  190.             return view(request, *args, **kwargs)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/utils/decorators.py" in _wrapper
  21.             return decorator(bound_func)(*args, **kwargs)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/utils/decorators.py" in _wrapped_view
  76.                     response = view_func(request, *args, **kwargs)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/utils/decorators.py" in bound_func
  17.                 return func(self, *args2, **kwargs2)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/transaction.py" in _commit_on_success
  299.                     res = func(*args, **kw)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/contrib/admin/options.py" in add_view
  796.                 form.save_m2m()
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/forms/models.py" in save_m2m
  83.                 f.save_form_data(instance, cleaned_data[f.name])
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/fields/related.py" in save_form_data
  1140.         setattr(instance, self.attname, data)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/fields/related.py" in __set__
  730.         manager.clear()
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/fields/related.py" in clear
  506.             self._clear_items(self.source_field_name)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/fields/related.py" in _clear_items
  626.                 source_field_name: self._pk_val
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/query.py" in delete
  440.             for i, obj in izip(xrange(CHUNK_SIZE), del_itr):
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/query.py" in _result_iter
  106.                 self._fill_cache()
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/query.py" in _fill_cache
  760.                     self._result_cache.append(self._iter.next())
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/query.py" in iterator
  269.         for row in compiler.results_iter():
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/sql/compiler.py" in results_iter
  672.         for rows in self.execute_sql(MULTI):
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/models/sql/compiler.py" in execute_sql
  727.         cursor.execute(sql, params)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/django/db/backends/util.py" in execute
  15.             return self.cursor.execute(sql, params)
File "/Users/celopes/dev/workspace/techsupport_django/lib/python2.6/site-
packages/sql_server/pyodbc/base.py" in execute
  313.         return self.cursor.execute(sql, params)

Original issue reported on code.google.com by ce.lo...@gmail.com on 7 Jun 2010 at 4:08

GoogleCodeExporter commented 8 years ago
Please close this issue. It was a problem between the chair and the keyboard.

By creating a proxied field and having a many to many relationship in one of my 
objects - the underlying db 
column changed in the relationship model and my database table was not 
reflecting that.

Original comment by ce.lo...@gmail.com on 7 Jun 2010 at 4:19

GoogleCodeExporter commented 8 years ago

Original comment by vcc.ch...@gmail.com on 19 Jun 2010 at 8:26