[Django] #12190: Changeset [11710] breaks ForeignKey.db_type for fields defined outside a model

View: New views
3 Messages — Rating Filter:   Alert me  

[Django] #12190: Changeset [11710] breaks ForeignKey.db_type for fields defined outside a model

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12190: Changeset [11710] breaks ForeignKey.db_type for fields defined outside a
model
------------------------------------------+---------------------------------
 Reporter:  jittat                        |       Owner:  nobody    
   Status:  new                           |   Milestone:            
Component:  Database layer (models, ORM)  |     Version:  SVN      
 Keywords:  multi-db, ForeignKey          |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 When defining a ForeignKey field outside a model, ForeignKey.db_type
 produces an exception FieldDoesNotExist.  This bug breaks '''south
 0.6.2''', and starts occurring after changeset [11710].

 '''Steps to reproduce'''

 1. Assume that you already have a Poll model defined as in the tutorial

 2. In `manage.py shell`, do the following

 {{{
 #!python
 from polls.models import Poll
 from django.db import models
 poll = models.ForeignKey(Poll)
 poll.db_type()
 }}}

 You expect to see `'integer'` (on revision [11709], you see it), but
 you'll get the following:

 {{{
   File "<console>", line 1, in <module>
   File "/usr/lib/python2.6/dist-
 packages/django/db/models/fields/related.py", line 771, in db_type
     rel_field = self.rel.get_related_field()
   File "/usr/lib/python2.6/dist-
 packages/django/db/models/fields/related.py", line 648, in
 get_related_field
     data = self.to._meta.get_field_by_name(self.field_name)
   File "/usr/lib/python2.6/dist-packages/django/db/models/options.py",
 line 299, in get_field_by_name
     % (self.object_name, name))
 FieldDoesNotExist: Poll has no field named None
 }}}

 '''Additional information'''

 After some tracing, I think this bug is related to the removal of line 693
 in source:/django/trunk/django/db/models/fields/related.py#11710 in
 changeset [11710].  The following line is removed:
 {{{
 #!python
             to_field = to_field or to._meta.pk.name
 }}}

--
Ticket URL: <http://code.djangoproject.com/ticket/12190>
Django <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 django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12190: Changeset [11710] breaks ForeignKey.db_type for fields defined outside a model

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12190: Changeset [11710] breaks ForeignKey.db_type for fields defined outside a
model
---------------------------------------------------+------------------------
          Reporter:  jittat                        |         Owner:  nobody              
            Status:  new                           |     Milestone:                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                
        Resolution:                                |      Keywords:  multi-db, ForeignKey
             Stage:  Unreviewed                    |     Has_patch:  0                  
        Needs_docs:  0                             |   Needs_tests:  0                  
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by jittat):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 Sorry, the link to the original file is wrong (it points to the file
 '''after''' the change of [11710]).  The correct link is line 693 in
 source:/django/trunk/django/db/models/fields/related.py#11709#L693.

--
Ticket URL: <http://code.djangoproject.com/ticket/12190#comment:1>
Django <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 django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12190: Changeset [11710] breaks ForeignKey.db_type for fields defined outside a model

by noreply-71 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12190: Changeset [11710] breaks ForeignKey.db_type for fields defined outside a
model
---------------------------------------------------+------------------------
          Reporter:  jittat                        |         Owner:  nobody              
            Status:  closed                        |     Milestone:                      
         Component:  Database layer (models, ORM)  |       Version:  SVN                
        Resolution:  fixed                         |      Keywords:  multi-db, ForeignKey
             Stage:  Unreviewed                    |     Has_patch:  0                  
        Needs_docs:  0                             |   Needs_tests:  0                  
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by russellm):

  * status:  new => closed
  * resolution:  => fixed

Comment:

 (In [11730]) Fixed #12190 -- Corrected a regression in the ability to
 instantiate ForeignKeys? outside of models. Thanks to jittat for the
 report.

--
Ticket URL: <http://code.djangoproject.com/ticket/12190#comment:2>
Django <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 django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---