def stats(self, start_date=None, end_date=None, registered_only=False):
pageviews = self.filter(<EOL>visitor__start_time__lt=end_date,<EOL>visitor__start_time__gte=start_date,<EOL>).select_related('<STR_LIT>')<EOL>stats = {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>}<EOL>stats['<STR_LIT>'] = total_views = pageviews.count()<EOL>unique_count = <NUM_LIT:0><EOL>if not total_views:<EOL><INDENT>return stats<EOL><DEDENT>registered_pageviews = pageviews.filter(visitor__user__isnull=False)<EOL>registered_count = registered_pageviews.count()<EOL>if registered_count:<EOL><INDENT>registered_unique_count = registered_pageviews.values(<EOL>'<STR_LIT>', '<STR_LIT:url>').distinct().count()<EOL>unique_count += registered_unique_count<EOL>stats['<STR_LIT>'] = {<EOL>'<STR_LIT>': registered_count,<EOL>'<STR_LIT>': registered_unique_count,<EOL>}<EOL><DEDENT>if TRACK_ANONYMOUS_USERS and not registered_only:<EOL><INDENT>guest_pageviews = pageviews.filter(visitor__user__isnull=True)<EOL>guest_count = guest_pageviews.count()<EOL>if guest_count:<EOL><INDENT>guest_unique_count = guest_pageviews.values(<EOL>'<STR_LIT>', '<STR_LIT:url>').distinct().count()<EOL>unique_count += guest_unique_count<EOL>stats['<STR_LIT>'] = {<EOL>'<STR_LIT>': guest_count,<EOL>'<STR_LIT>': guest_unique_count,<EOL>}<EOL><DEDENT><DEDENT>stats['<STR_LIT>'] = unique_count<EOL>return stats<EOL>
Returns a dictionary of pageviews including:

            * total pageviews

        for all users, registered users and guests.