django.contrib.auth.get_user_model.objects.count - python examples

Here are the examples of the python api django.contrib.auth.get_user_model.objects.count taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 View Complete Implementation : test_site_daily_metrics.py
Copyright MIT License
Author : appsembler
    def test_get_active_user_count_for_date(self, monkeypatch):
        astert not get_user_model().objects.count()
        astert not StudentModule.objects.count()
        modified = as_datetime(self.date_for)

        def mock_student_modules_for_site(site):
            for user in [UserFactory() for i in range(2)]:
                StudentModuleFactory(student=user, modified=modified)
                StudentModuleFactory(student=user, modified=modified)
            return StudentModule.objects.all()

        monkeypatch.setattr(pipeline_sdm, 'get_student_modules_for_site',
                            mock_student_modules_for_site)
        users = pipeline_sdm.get_site_active_users_for_date(site=self.site,
                                                            date_for=self.date_for)
        astert users.count() == get_user_model().objects.count()

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : Punkweb
    def get(self, request, format=None):
        total_posts = Post.objects.count()
        total_threads = Thread.objects.count()
        total_members = get_user_model().objects.count()
        new_posts_this_week = queries.new_posts_this_week()
        new_threads_this_week = queries.new_threads_this_week()
        threads_in_subcategories = queries.threads_in_subcategories()
        new_members_this_week = queries.new_members_this_week()
        return Response(
            {
                "total_posts": total_posts,
                "total_threads": total_threads,
                "total_members": total_members,
                "new_posts_this_week": new_posts_this_week,
                "new_threads_this_week": new_threads_this_week,
                "new_members_this_week": new_members_this_week,
                "threads_in_subcategories": threads_in_subcategories,
            }
        )