Open sirmaahe opened 7 years ago
Yep that's a good idea, and we should also allow toggling the sharing (and related filtering) for user/group in settings.
P.s: Pull requests are welcome 😄
Is there a workaround for that?
Hi @sbrunner , try adding the attribute checking suggested by @sirmaahe , on this method :
I.e:
advanced_filters/models.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/advanced_filters/models.py b/advanced_filters/models.py
index 2c9f749..f19c532 100644
--- a/advanced_filters/models.py
+++ b/advanced_filters/models.py
@@ -9,7 +9,8 @@ from .q_serializer import QSerializer
class UserLookupManager(models.Manager):
def filter_by_user(self, user):
"""All filters that should be displayed to a user (by users/group)"""
-
+ if not hasattr(user, 'groups'):
+ return self.filter(users=user)
return self.filter(Q(users=user) | Q(groups__in=user.groups.all()))
If it works for you, give back to the community by submitting a PR (with a unit test please, and some docs update would be nice).
OK, Thanks :-)
can any one help me for my query. Please
Table 1
User and id [pk], username
Table 2
group and id [pk], group_name
Table 2
user_groups and id[pk],user_id [fk of Table1] , group_id,[fk of Table2]
how i get how i get all users and their user group??
eg.
Table 1
id , username
1 ,xyz
2,abc
3,lmn
Table 2
id , group_name
1, admin
2, user
3,staff
Table 2
id[pk],user_id , group_id
1 , 1, 1
2, 2 2
3 3 1
expected result
1 ,xyz , admin
2,abc, user
3,lmn,staff
i one django query , i can do with raw query but i need in django style query please help me
i do as follow but failed
result = User.groups.objects.all()
but it give me error
'ManyToManyDescriptor' object has no attribute 'objects'
please tell me, from django admin related table , how can i show all user and their user group report please
I created a PR for it. It was easy enough. I want to use this plugin maybe. I've been playing around with it. It's quite nice, however a bit complex to use. Ok for developers but more complex for managers.
But I understand that it's not easy to make a user-friendly UI in the Django admin. It's not great but with a bit of modification and plugins it is just good enough to not make a custom admin yourself. At least it saves some work for as long as it suffices.
So thanks for the plugin. I hope this PR is will be accepted and that the plugin will be accessible to more people. Maybe I'll do some more hacking on this some time.
Cheers
Hello!
I have custom User model, which inherits AbstractBaseUser and doesn't have Group relation. So when i use filter mixin, i get this exception:
Can you add a attribute checking in _UserLookupManager.filter_byuser or something?