I'm learning django.
I want to count the number of clicks to the URL on the page that puts the title and URL of the news article on the net as a model in mysql and displays it as a list.
class News (models.Model): news_title = models.TextField () news_url = models.TextField () view_number = models.IntegerField (blank = False, default = 0)
Actually on the page
I'm arranging the news in the display, and I want to increase the value of view_number when clicked so that the number of clicks can be displayed next to the article.
Answer # 1
When writing to views
This calls the DB directly in that function to increase the count
Since it is called when accessing the URL, it will be counted even if you copy and paste the URL.
So this is something like the number of impressions
When you click the link, it will be sent to the DB using ajax etc. and then skipped to the link.
Unlike the above, this will remember the number of times the link was clicked, so
If you copy the URL of news and access it, it will not be recorded
So it seems that it depends on the application.
- python - i want to change the ip address that the django app gets by default from remote_addr to http_x_forwarded_for in middlew
- website button clicks in selenium and python
- python - django image folder reasons to create static and madia folders separately
- python - count by element with pivot_table in pandas
- python - about image deletion in django
- python - object is not displayed in html in django queryset
- name error in underscore in python django
- python - [django] gte works with filter in queryset, but lt doesn't work and i can't get the specified range of data
- python - i can't find some url paths after deploying django
- how to count days of the week python
- python - django form i want to write a little smarter
- extract title and video count with python youtube api
- python - when i set the uuid field in django, i get field'object_id' expected a number but got '78a0767cb607488087a73f17565bb
- python - i want to record on a mac!
- python - when will you start the startapp in django?
- python - the table element generated by the django template variable is output at the bottom of the page
- python - how to read the record information after 10 seconds
- python - [django] read csv file from url
- python - i get an argument must be int or float error in django
- python : Order operation logic and basket Django
- python : How to change the entry in the database using Django ORM in one request
- python : How to display objects associated via ForeignKey in Django pattern?
- python : Models and forms in Django
- python : How to make username from other fields?
- python : PycharmPro Installation Error
- python : Download Django Server File
- python : Model with quantity in Django ORM
- python : Django Forms auto-generated field
- python : Django debugging can not import modules when you are Visual Studio Code