For my project, I am trying to generate a csv-file to be read in dygraphs. Dygraphs is a Javascript library that graphs a csv-file. In the Dygraphs' documentation, it says when you specify a file, it sends an XHR to get the csv. So, in my views, I interpreted that as I need a
if request.is_ajax():
But is that really what it means?
My problem is that my dygraphs won't display on the page. The error message that I'm getting from Firebug is:
"NetworkError: 404 Not Found - http://www.albedo.csrcdev.com/VAM/Appearance/VAMStyleSheet.css
"NetworkError: 404 Not Found - http://www.albedo.csrcdev.com/VAM/3_0_3/VAM.js/
ReferenceError: VAM_ValSumFmtBullet is not defined
ReferenceError: VAM_GetById is not defined
I don't really know what that is telling me, but when I had a static csv file, the graph did display so I'm pretty sure it's just not grabbing the dynamically created csv file.
Any help is appreciated.
Thanks
# The function does work, when I type the url manually, it prompts me
# to download the csv and is all correct.
def dygraphs_generate_csv( request, year=None ):
if request is_ajax():
if year is None:
year = datetime.today().year
entries = DataEntry.objects.all().filter(observation_Date__year=year)
return render( request, 'pages/output.csv',
{'entries': entries},
content_type='text/csv'
)