- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Django model object hit counting
In this article, we are going to make a project in which we will see how to make a Django table that will store all the data of hit count and detailed data of hit. It can be used generate useful reports. So, let's get started.
Setup your urls.py and install the django-hitcount module
pip install django-hitcount
Example
In settings.py, add the following line −
INSTALLED_APPS+ = ['hitcount']
Here we added this library as an app in the project.
Run the following commands −
python manage.py makemigrations python manage.py migrate
Here, we create migrations and then we migrate it.
That's all. This library will create a table that will store all the data.
Output
Go to http://127.0.0.1 and login
Hit counts and Hits contain what we wanted, you can explore other two.
Advertisements