Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

Django Model Object Hit Counting


บทความนี้สร้างโปรเจกต์ที่มีตาราง Django เก็บข้อมูล Hit Count และรายละเอียด Hit ใช้สร้างรายงานที่มีประโยชน์

ตัวอย่าง

ตั้งค่า urls.py ติดตั้ง django-hitcount:

pip install django-hitcount

ใน settings.py:

INSTALLED_APPS+= ['hitcount']

เพิ่มไลบรารีเป็นแอป

รันคำสั่ง:

python manage.py makemigrations
python manage.py migrate

สร้าง migrations และ migrate ไลบรารีจะสร้างตารางเก็บข้อมูล hit count อัตโนมัติ

เอาต์พุต

เข้า https://127.0.0.1 login

Hit counts และ Hits มีข้อมูลที่ต้องการ สามารถสำรวจอื่นๆ ได้

Django Model Object Hit Counting