i have app called 'funds' has 2 models: fund, , performance. performance tracks fund. trying graph performance using d3.js. came across error:
noreversematch @ /funds/morning-glory-volatility-fund/
reverse 'performance_api' arguments '()' , keyword arguments '{}' not found. 1 pattern(s) tried: ['funds/(?p[\w-]+)/performance/api']
here view using pass jsonresponse:
def performance_api(request, fund_slug): fund = get_object_or_404(fund, slug=fund_slug) data = performance.objects.filter(fund__name=fund.name) \ .extra(select={'month': connections[performance.objects.db].ops.date_trunc_sql('month', 'date')}) \ .values('month') \ .annotate(count_items=count('id')) return jsonresponse(list(data), safe=false)
and urls.py funds app:
url(r'^(?p<fund_slug>[\w-]+)/performance/api', views.performance_api, name='performance_api'),
there global urls.py includes url of apps. access performance_api in broswer this: '127.168.1.1/funds/fund_slug/perfomance/api' seems working.
as d3 code 40 lines post portion seems causing issue:
d3.json("{% url 'performance_api' %}", function(error, data) { data.foreach(function(d) { d.month = parsedate(d.month); d.count_items = +d.count_items; });
any idea on what's causing issue , how can solve it? thanks.
the url pattern performance_api
features 1 named argument (fund_slug
). in order url
tag reverse url, need provide information, e.g.
d3.json("{% url 'performance_api' fund_slug="morning-glory-volatility-fund" %}", function(error, data) { //... }
Comments
Post a Comment