[Answered ]-Django app with Rails API

2👍

Suggestion

views.py

data = [{'created_at': None, 'account_username': 'woof', 'id': 12, 'updated_at': None, 'account_password': 'woof', 'user_id': 3, 'account_type': 'credit', 'institution_name': 'test'}, {'created_at': None, 'account_username': 'ge', 'id': 22, 'updated_at': None, 'account_password': 'ge', 'user_id': 3, 'account_type': 'checking', 'institution_name': 'test2'}]

print type(data) ## list
result_data = {}
result_data['data'] = data

print type(result_data) ## dict    
print "FFFFFFFFFFFFFFFFFFFFFFfffffffffffffffffffffffffff"
ddd = json.dumps(result_data)
dd = json.loads(ddd)

return render(request,'accounts.html',
        {
          'accounts':dd['data'],
        }
    )


## HTML
{% for account in accounts %}
          <div class="card small>
            <div class="card-content white-text">
              <span class="card-title no_margin">
                {{ account.account_name }}
              </span>
              <span class="card_subtitle">
                {{ account.account_type }}
                <span class="right">Balance</span>
              </span>
            </div>
{% endfor %}
👤Cadmus

Leave a comment