annotate django queryset code example
Example 1: django pandas queryset
import pandas as pd
import datetime
from myapp.models import BlogPost
df = pd.DataFrame(list(BlogPost.objects.all().values()))
df = pd.DataFrame(list(BlogPost.objects.filter(date__gte=datetime.datetime(2012, 5, 1)).values()))
df = pd.DataFrame(list(BlogPost.objects.all().values('author', 'date', 'slug')))
Example 2: objects.filter django
>>> Entry.objects.filter(blog_id=4)
Example 3: django order by
class Meta:
ordering = ('yourfeild',)
Example 4: django filter exsist
if table.objects.filter(prop='value').count() > 0:
Example 5: django queryset count
Entry.objects.count()
Entry.objects.filter(headline__contains='Lennon').count()