Re: Annotate django user queryset with group names

2016-07-22 Thread Todor Velichkov
This is actually a pretty good solution and I totally forgot about it! It will help people for sure! On Saturday, July 23, 2016 at 1:29:42 AM UTC+3, mishbah wrote: > > While I was waiting for suggestions, I did some more research learnt about > django Conditional Expressions. > > Docs: > https

Re: Annotate django user queryset with group names

2016-07-22 Thread mishbah
While I was waiting for suggestions, I did some more research learnt about django Conditional Expressions. Docs: https://docs.djangoproject.com/en/1.9/ref/models/conditional-expressions/ from django.contrib.auth.models import User from django.db.models import BooleanField from djang

Re: Annotate django user queryset with group names

2016-07-22 Thread mishbah
You are awesome! Thank you! On Friday, 22 July 2016 21:41:58 UTC+1, Todor Velichkov wrote: > > Hello, I don't think sub-classing `Func` would be appropriate here. A much > easier way would be to use `RawSQL > > `

Re: Annotate django user queryset with group names

2016-07-22 Thread Todor Velichkov
Hello, I don't think sub-classing `Func` would be appropriate here. A much easier way would be to use `RawSQL ` since you want to dynamically check for different group you could write a factory method to build `

Annotate django user queryset with group names

2016-07-22 Thread Mishbah Razzaque
Given that I have a django model that has a ForeignKey that is linked to itself. class DjangoModel(): [...] successor = models.ForeignKey('self', null=True) I was able to write a custom django database function like this: from django.db.models import BooleanFie