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 [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-developers?hl=en.