Quantcast

how a field and its value can be found in a queryset object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

how a field and its value can be found in a queryset object

wuuuuu
Hi, 

first, I have such an example: 

  1. users = Some.objects.filter(user="someone")
  2. users.update(price=100)
based on different user (I have a table to save it), users go to the different databases, and due to Master/Slave seperated,  update and filter should be in different places as well). So in line 2, I need to find whether the queryset has a special where field user, and get the db connection based on the user. 


My code looks like: 

from django.db.models.query import QuerySet

class UserQuerySet(QuerySet):

        def update(self):

              # please let me know how I can get user from self
             user = some_way_to_get_user(self)
             db = get_db_for_write(user)
             self.db = db
             super(UserQuerySet, self).update()

My problem lies in the blue part of above code, please let me know how I can achieve this. 

I've looked at the code, which might have something like: 

     def update(self):



--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/aNe_X_nEBHAJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: how a field and its value can be found in a queryset object

Karen Tracey-2
Please ask questions about using Django on django-users. The topic of this list is the development of Django itself.

Karen

--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Loading...