Re: [Django] #12883: Adding values in a m2m field breaks (_state.db is None instead of "default")

2010-03-04 Thread Django
#12883: Adding values in a m2m field breaks (_state.db is None instead of
"default")
---+
  Reporter:  IonelMaries   | Owner:  nobody
Status:  closed| Milestone:  1.2   
 Component:  Database layer (models, ORM)  |   Version:  SVN   
Resolution:  duplicate |  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * status:  reopened => closed
  * resolution:  => duplicate

Comment:

 I believe this is actually a duplicate of #13003. The issue is the
 select_related call not populating the _state.db of the related user
 object, which then causes the m2m assignment to fail.

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



Re: [Django] #12883: Adding values in a m2m field breaks (_state.db is None instead of "default")

2010-03-04 Thread Django
#12883: Adding values in a m2m field breaks (_state.db is None instead of
"default")
---+
  Reporter:  IonelMaries   | Owner:  nobody
Status:  reopened  | Milestone:  1.2   
 Component:  Database layer (models, ORM)  |   Version:  SVN   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by ext):

  * status:  closed => reopened
  * resolution:  invalid =>

Comment:

 I'm reopening, because, I've got the same problem.

 Code causing the problem is:

 {{{
 (...)
 project = form.save()
 admin_profiles =
 Member.objects.select_related().filter(group__name='Admin')
 for admin_profile in admin_profiles:
 project.users.add(admin_profile.user)
 }}}

 It is just adding users to a project.users which is m2m to auth.User.
 Error report is:
 {{{
 Traceback (most recent call last):
  File "/var/www/django/someapp/parts/django/django/core/handlers/
 base.py", line 101, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File "/var/www/django/someapp/webshare/utils.py", line 21, in wrapper
context = view_func(*args, **kwargs)
  File "/var/www/django/someapp/webshare/apps/projects/views.py", line
 100, in add_project
project.users.add(admin_profile.user)
  File "/var/www/django/someapp/parts/django/django/db/models/fields/
 related.py", line 465, in add
self._add_items(self.source_field_name, self.target_field_name,
 *objs)
  File "/var/www/django/someapp/parts/django/django/db/models/fields/
 related.py", line 525, in _add_items
(obj, self.instance._state.db, obj._state.db))
 ValueError: Cannot add "": instance is on database
 "default", value is is on database "None"
 }}}

 It is actually very strange. After I had used pdb and went through the
 code slowly there were no error! However during normal execution there
 is still a problem.

 I found that something goes wrong inside
 allow_relation method in django.db.utils. Last line of this function
 is:
 {{{
 return obj1._state.db == obj2._state.db
 }}}

 But when I print these variables i get:

 without pdb:

  * obj1._state.db:  None
  * obj2._state.db:  default

 with pdb (I mean step by step execution):
  * obj1._state.db:  default
  * obj2._state.db:  default

 Also see discussion here: http://groups.google.pl/group/django-
 users/browse_thread/thread/a81d6618fce29436?pli=1

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



Re: [Django] #12883: Adding values in a m2m field breaks (_state.db is None instead of "default")

2010-02-16 Thread Django
#12883: Adding values in a m2m field breaks (_state.db is None instead of
"default")
---+
  Reporter:  IonelMaries   | Owner:  nobody
Status:  closed| Milestone:  1.2   
 Component:  Database layer (models, ORM)  |   Version:  SVN   
Resolution:  invalid   |  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * status:  new => closed
  * resolution:  => invalid
  * milestone:  => 1.2

Comment:

 This is a concerning report because it covers an area of new functionality
 -- but as @semenov says, there's nowhere near enough detail to replicate
 the problem.

 Marking Invalid due to the lack of info. If you can provide a full test
 case (models and the sequence of calls that leads to the problem) please
 reopen. Alternatively, ask on django-users to confirm that you have
 correct usage.

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



Re: [Django] #12883: Adding values in a m2m field breaks (_state.db is None instead of "default")

2010-02-16 Thread Django
#12883: Adding values in a m2m field breaks (_state.db is None instead of
"default")
---+
  Reporter:  IonelMaries   | Owner:  nobody
Status:  new   | Milestone:
 Component:  Database layer (models, ORM)  |   Version:  SVN   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by semenov):

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

Comment:

 IonelMaries, do you realize that in order to fix a bug, it needs to be
 repeated and confirmed first? How do you think anyone would '''repeat'''
 the bug based solely on your description?

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



[Django] #12883: Adding values in a m2m field breaks (_state.db is None instead of "default")

2010-02-16 Thread Django
#12883: Adding values in a m2m field breaks (_state.db is None instead of
"default")
--+-
 Reporter:  IonelMaries   |   Owner:  nobody
   Status:  new   |   Milestone:
Component:  Database layer (models, ORM)  | Version:  SVN   
 Keywords:|   Stage:  Unreviewed
Has_patch:  0 |  
--+-
 {{{
 Traceback (most recent call last):
   File "x.py", line 123, in process_release
 bla.somem2mfield.add(foo)
   File "/home/snip/ve/src/django/django/db/models/fields/related.py", line
 465, in add
 self._add_items(self.source_field_name, self.target_field_name, *objs)
   File "/home/snip/ve/src/django/django/db/models/fields/related.py", line
 525, in _add_items
 (obj, self.instance._state.db, obj._state.db))
 ValueError: Cannot add "": instance is on database
 "None", value is is on database "default"
 }}}

 I don't understand why this happens. I don't have any explicit "using"
 anywhere in my code.

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