Skip to content

Commit

Permalink
Merge pull request #1 from QueraTeam/feature/reset_visits
Browse files Browse the repository at this point in the history
Add reset_visits method
  • Loading branch information
mjnaderi authored Apr 17, 2023
2 parents a0b7b39 + ccfbac1 commit 9fcfc02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions django_visit_count/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ def count_visit(self, request, session_duration=VISIT_COUNT_DEFAULT_SESSION_DURA
if is_new_visit(request, self, session_duration=session_duration):
self.visit_count = models.F("visit_count") + 1
self.save(update_fields=["visit_count"])

def reset_visits(self, save=True):
self.visit_count = 0
if save:
self.save(update_fields=["visit_count"])
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="django-visit-count",
version="1.1.0",
version="1.1.1",
description="Count visits using cache for Django models",
long_description=README,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 9fcfc02

Please sign in to comment.