2021年1月3日星期日

Why django TemplateSyntaxError is raised in here?

Im tring to iterate through context of my view and get 'ga:deviceCategory' values only , the code that I'm running in HTML is:

<div class="card-body">      </div>  

My view in django is :

def dashboard(request):    context = {'pvdc': [{'ga:deviceCategory': 'desktop', 'ga:pageviews': 673, 'ga:avgSessionDuration': 53.4447946},  {'ga:deviceCategory': 'mobile', 'ga:pageviews': 2373, 'ga:avgSessionDuration': 69.62674418604651},  {'ga:deviceCategory': 'tablet', 'ga:pageviews': 322, 'ga:avgSessionDuration': 26.205426356589147}]}    return render(request, 'user/index.html', context)  

The syntax error that I receive is: Could not parse the remainder: '('ga:deviceCategory')' from 'i.get('ga:deviceCategory')'

enter image description here

what is the problem here and how can i get the values?

https://stackoverflow.com/questions/65547798/why-django-templatesyntaxerror-is-raised-in-here January 03, 2021 at 04:07PM

没有评论:

发表评论