Menu

Post image 1
Post image 2
1 / 2
0

How I Added Live Charts to the Django Admin Without Installing a Single Package

DEV Community: django·Vicente G. Reyes·3 days ago
#UsHevVj9
#dev#chart#admin#django#extra_context#days
Reading 0:00
15s threshold

The Django admin is a powerful tool that most developers underuse. Out of the box it gives you a filterable, searchable table for every model — but it stops short of anything visual. If you want to see trends over time, you're staring at rows. I recently added a PageVisit model to my portfolio backend to track which blog posts, projects, and services people actually read. After 73 visits in two days I realised most of them were bots — but that problem aside, I also wanted a fast way to see visit trends without leaving the admin. Here's how I wired up three Chart.js charts with no new Python dependencies. The Setup The PageVisit model records one row per visit: class PageVisit ( models . Model ): PAGE_TYPE_CHOICES = [ ( " blog_post " , " Blog Post " ), ( " project " , " Project " ), ( " service " , " Service " ), ] DEVICE_TYPE_CHOICES = [ ( " desktop " , " Desktop " ), ( " mobile " , " Mobile " ), ( " tablet " , " Tablet " ), ( " bot " , " Bot " ), ( " unknown " , " Unknown " ), ] page_type = models .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More