मैं एक डैशबोर्ड बनाने की कोशिश कर रहा हूं जहां मैं पुस्तकालय plotly का उपयोग कर अपने मॉडल के डेटा (आलेख) का विश्लेषण कर सकता हूं।Django पर प्लॉटली के साथ चार्ट कैसे बनाएं?
Plotly बार चार्ट मेरे टेम्पलेट पर नहीं दिखा रहा है वहाँ नीचे कोड के साथ कोई त्रुटि है के बाद से, मैं अगर मैं कुछ गलत कर रहा हूँ सोच रहा हूँ:
models.py
from django.db import models
from django.contrib.auth.models import User
import plotly.plotly as py
import plotly.graph_objs as go
class Article(models.Model):
user = models.ForeignKey(User, default='1')
titre = models.CharField(max_length=100, unique=True)
slug = models.SlugField(max_length=40)
likes = models.ManyToManyField(User, related_name="likes")
def __str__(self):
return self.titre
@property
def article_chart(self):
data = [
go.Bar(
x=[self.titre], #title of the article
y=[self.likes.count()] #number of likes on an article
)
]
plot_url = py.plot(data, filename='basic-bar')
return plot_url
dashboard.html
<div>{{ article.article_chart }}</div>
क्यों बार चार्ट दिखाई नहीं देता है? कोई उपाय ?
'' article_chart' Article' की संपत्ति है, तो आप के रूप में 'इसे संदर्भ की आवश्यकता होगी {{article.article_chart}}' अपने खाके में। – Franey