#6706: updating inherited models does not work
------------------------------+---------------------------------------------
Reporter:  dcwatson           |       Owner:  nobody                  
  Status:  new                |   Component:  Database wrapper        
 Version:  queryset-refactor  |    Keywords:  model inheritance update
   Stage:  Unreviewed         |   Has_patch:  0                       
------------------------------+---------------------------------------------
 Saving initial instances of inherited models works as expected. However,
 when trying to update a field, a `FieldDoesNotExist` exception is thrown.
 For example, assume the following models:

 {{{
 class Location (models.Model):
     name = models.CharField( max_length=100 )

 class PersonInfo (models.Model):
     first_name = models.CharField( max_length=100 )
     last_name = models.CharField( max_length=100 )

 class Employer (PersonInfo):
     title = models.CharField( max_length=100 )
     office = models.ForeignKey( Location, related_name='employers' )
 }}}

 Then try the following:

 {{{
 office = Location( name='The Office' )
 office.save()
 boss = Employer( first_name='Dan', last_name='Watson', title='Boss',
 office=office )
 boss.save()

 # the following will break
 boss.title = 'Some Other Title'
 boss.save()
 }}}

 This is the traceback I get:

 {{{
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/home/dcwatson/python_packages/django/db/models/base.py", line
 268, in save
     self.save(raw, parent)
   File "/home/dcwatson/python_packages/django/db/models/base.py", line
 286, in save
     manager.filter(pk=pk_val).update(**dict(values))
   File "/home/dcwatson/python_packages/django/db/models/query.py", line
 258, in update
     query.add_update_values(kwargs)
   File
 "/home/dcwatson/python_packages/django/db/models/sql/subqueries.py", line
 210, in add_update_values
     field, model, direct, m2m = self.model._meta.get_field_by_name(name)
   File "/home/dcwatson/python_packages/django/db/models/options.py", line
 253, in get_field_by_name
     % (self.object_name, name))
 FieldDoesNotExist: PersonInfo has no field named 'office'
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/6706>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to