python - fetch data using count function in django -


am trying fech data database using count function in django, whenever try code using tablename.objects.count() working fine. ehan try :-

views.py:-

def home(request):     getsessionuserid = request.session['getuser_id']     getlatestproject = jobs.objects.all()     getcountvalues = applicationform.objects.count(user_id=getsessionuserid)         getinterviewcount = interview.objects.count()        getjobscount = jobs.objects.count()     return render_to_response(     'home.html',     { 'user': request.user, 'getlatestproject': getlatestproject , 'getcountvalues': getcountvalues, 'getinterviewcount': getinterviewcount , 'getjobscount': getjobscount }     )  

than display error:-

count() got unexpected keyword argument 'user_id'

i want count data in condition user_id=getsessionuserid dispaly error.

the count() method not take arguments. can filter queryset first, use count. example:

published_count = book.objects.filter(published=true).count() 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -