-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
57 lines (56 loc) · 3.25 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class OrganizationDetail(RelatedJobsPreventDeleteMixin, RetrieveUpdateDestroyAPIView):
#Book.objects.filter(author="Bob").filter(color="red")
#entry = Entry.objects.get(pk=1)
#entry.authors
#q = entry.filter(a=a)
#authors = []
#for entry in Entry.objects.all():
# authors.append(entry.authors)
#for entry in Entry.objects.all():
# var = entry.authors
#PaymentMethod.objects.filter(user=User.objects.all(a=a))
#payment_method, _ = PaymentMethod.objects.get_or_create(**payment_data)
#queryset = models.PaymentMethod.objects.all()
#queryset = PaymentMethod.objects.all().get_or_create(**payment_data).filter(a=a)
#Project.objects.filter(writer__name__fname='Sophie')
#is_owner = Q(owner_id=self.user_id)
#is_owner = Q(owner=self.user_id)
#is_owner = Q(owner_id=self.user_id)
#is_member = ~Q(member__user_id=self.user_id)
#q = Project.objects.filter(is_owner | is_member)
#q = Project.objects.filter(is_member)
#q = Project.objects.filter(is_owner)
#def get_serializer_context(self, *args, **kwargs):
#b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.')
#q = Book.objects.annotate(Count('authors'))
#q = Profile.objects.filter(~Q(new__day=self.owner))
#instances = Instance.objects.filter(~Q(hostname=None), enabled=True)
#q = Profile.objects.filter(Q(user=self.owner) | ~Q(user__memberships__project=self))
#Poll.objects.get( Q(pub_date=date(2005, 5, 2)) | Q(pub_date=date(2005, 5, 6)), question__startswith='Who')
#-- test make sure query to right works with delete model (chaining queries) --> q = Entry.objects.order_by(Coalesce('summary', 'headline')).annotate(Count('b', 'c'))
#q.aggregate(Count('entry', 'f')).annotate(Count('a', 'd')).order_by(Lower('E'))
#above_5 = Count('book', filter=Q(book__rating__gt=5))
#below_5 = Count('book', filter=Q(book__rating__lte=5))
#pubs = Publisher.objects.annotate(below_5=below_5).annotate(above_5=above_5).annotate(test=Count('test'))
#direct_counts = (
# Organization.objects.filter(id=org_id)
# .annotate(users=Count('member_role__members', distinct=True), admins=Count('admin_role__members', distinct=True))
# .values('users', 'admins')
#)
#Book.objects.aggregate(Count('authors'), Count('store'))
#q = Tissue.objects
#q = q.annotate(user=Count('users'))
#q.filter(user=a).filter(user=b)
#Apple.objects.annotate(a=a).filter(a=a)
#Orange.objects.filter(a=a)
#q = Watermelon.objects.annotate(seeds=Count('yes'))
#q = q.filter(seeds=yes)
#q.filter(seeds=no).filter(c=c).annotate(seeds=yes)
#q.values('user').order_by('user').order_by("b")
#Publisher.objects.annotate(Count('test')).annotate(Count('test1')).annotate(Count('test2'))
#q = Blog.objects.order_by("-id").filter(alive="YES")
#q = Entry.objects.order_by('headline').filter(boo=boo)
#q = Tissue.objects.all()
#q.filter(fname="Bob").filter(lname="Adams")
#q = Blog.objects.aggregate(number_of_entries=Count('entry'))
#Pizza.objects.prefetch_related(Prefetch('restaurants', queryset=Restaurant.objects.select_related('best_pizza')))