I want to fetch the data from a table which is in database and then display it in tabular format in my webpage. Only the html column name is being shown but not the data from the database table. Can anyone please help me out with this?
My codes:
views.py:
def display_majorheads(request):
outputs = ProcessedOutputs.objects.all()
be_year = 0
context = {
'processed_outputs':outputs,
'be_year':be_year,
}
return render(request, 'website/mhead.html', context )
mhead.html:
<table class="table table-striped">
<tr>
<th>MajorHead</th>
<th>BeSalary</th>
<th>BeGiaSalary</th>
<th>BeOther</th>
<th>BeTotal</th>
<th>BeNextyrSalary</th>
<th>BeNextyrGiaSalary</th>
<th>BeNextyrOthrs</th>
<th>BeNextyrTotal</th>
</tr>
{% for processed_outputs in outputs %}
<tr>
<td>{{ processed_outputs.major_cd }}</td>
<td>{{ processed_outputs.be_salary }}</td>
<td>{{ processed_outputs.be_gia_salary }}</td>
<td>{{ processed_outputs.be_other }}</td>
<td>{{ processed_outputs.be_total }}</td>
<td>{{ processed_outputs.be_nextyr_salary }}</td>
<td>{{ processed_outputs.be_nextyr_gia_salary }}</td>
<td>{{ processed_outputs.be_nextyr_others }}</td>
<td>{{ processed_outputs.be_nextyr_total }}</td>
</tr>
{% endfor %}
</table>
almost there!
{% for processed_outputs in outputs %}
has to be:
{% for outputs in processed_outputs %}
{{ outputs.major_cd }}
...
...
Related
would like to change text color of win and loss to red and green
not sure how to accomplish this
<tbody>
{% for bet in bets %}
<tr>
<td>{{ bet.name }}</td>
<td>{{ bet.bet_summary }}</td>
<td>{{ bet.bet_content }}</td>
<td>{{ bet.game_start_date_and_time }}</td>
<td>{{ bet.rating | raw }}</td>
<td>{% if bet.bet_outcome is same as(0) %}
LOSS
{% elseif bet.bet_outcome is same as(1) %}
WIN
{% elseif bet.bet_outcome is same as(2) %}
PUSH
{% elseif bet.bet_outcome is same as(3) %}
CANCELLED
{% else %}
TBA
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
I am new to Django and I am trying to show the total employees and employees in each department in a table using a dropdown list.
Dropdown code :
<label>Depart</label>
<select class="custom-select" style="width: 200px" id="depart">
<option value="Total">Total</option>
{% for key,value in uv.items %}
<option value="{{ value }}">{{ key }}</option>
{% endfor %}
</select>
Table code :
<table class="table table-striped">
<tr class="thead-dark ">
<th>ID</th>
<th>Nom et Prenom</th>
<th>Lundi</th>
<th>Mardi</th>
<th>Mercredi</th>
<th>Jeudi</th>
<th>Vendredi</th>
<th>Samedi</th>
<th>Dimanche</th>
</tr>
{% for i in employe %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ i.name }} </td>
<td>{{ i.monday }}</td>
<td>{{ i.tuesday }}</td>
<td>{{ i.wednesday }}</td>
<td>{{ i.thursday }}</td>
<td>{{ i.friday }}</td>
<td>{{ i.saturday }}</td>
<td>{{ i.sunday }}</td>
</tr>
{% endfor %}
</table>
I want do report with HTML and put one column as title and supress repetition. I'm using Laravel 5.8.
This is my view code.
<div class="container">
<div class="table-responsive">
<div class="table table-striped table-bordered">
<table>
<thead>
<tr>
<th>Leito</th>
<th>Nº Atendimento</th>
<th>Dt. Atendimento</th>
<th>Paciente</th>
<th>Idade</th>
<th>CID Principal</th>
<th>CID</th>
<th>Médico</th>
<th>Dias internado</th>
<th>Observação</th>
</tr>
</thead>
<tbody>
#foreach($analytic as $patient)
<tr><td colspan="11"><strong>Setor: </strong>{{ $patient->setor }}</td></tr>
<tr class="{{ $patient->corlinha }}">
<td>{{ $patient->leito }}</td>
<td>{{ $patient->atendimento }}</td>
<td>{{ $patient->dtatendimento }}</td>
<td>{{ $patient->paciente }}</td>
<td>{{ $patient->idade }}</td>
<td>{{ $patient->cidp }}</td>
<td>{{ $patient->cid }}</td>
<td>{{ $patient->medico }}</td>
<td>{{ $patient->dias }}</td>
<td>{{ $patient->observacao }}</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
</div>
And this is my result:
Result
When "Setor" is same i need agroup them.
I need something like this:
Result that i need
Thank´s
In your case you need to groupBy your collection. I am giving an example.
Controller Code:
public function index()
{
$$analytic = Model::all()->groupBy('setor');
return view('view', compact('analytic '));
}
In blade your table will look like something:
<table>
#foreach ($analytic as $key => $data)
<tr>
<th colspan="10">{{ $key }}</th>
</tr>
#foreach ($data as $patient)
<tr>
<td>{{ $patient->leito }}</td>
<td>{{ $patient->atendimento }}</td>
<td>{{ $patient->dtatendimento }}</td>
<td>{{ $patient->paciente }}</td>
...........
...........
</tr>
#endforeach
#endforeach
</table>
Hope you can now work around to get your desired result. Read Laravel documentation about collection groupBy here.
I am trying to create a table with HTML tags but I am stuck with it.
I've tried to play with {% for i in list %}, but I couldn't find a solution.
list = {'ticker': tickers, 'price': prices}
<tbody>
<tr>
{% for i in price %}
<td>{{ i }}</td>
{% endfor %}
{% for i in ticker %}
<td>{{ i }}</td>
{% endfor %}
</tr>
<tr>
</tr>
</tbody>
I would see two columns one close to another, but I don't see any columns now.
try this
<tbody>
{% for i in list %}
<tr>
<td>{{ i.ticker }}</td>
<td>{{ i.price }}</td>
</tr>
{% endfor %}
</tbody>
for more details refer this
hope it helps
I am fairly new to Angular JS . I have a table like this .
<tr ng-repeat="job in jobs">
<td>{{ job.id }}</td>
<td>{{ job.companyName }}</td>
<td>{{ job.jobRole }}</td>
<td>{{ job.salary }}</td>
<td>{{ job.location }}</td>
<td>{{ job.jobTitle }}</td>
<td>{{ job.industry }}</td>
<td>{{ job.role }}</td>
<td>{{ job.aboutCompany }}</td>
<td>{{ job.natureOfWork }}</td>
<td>{{ job.idealCandidateProfile }}</td>
</tr>
and I am trying to fill it up using this .
function jobController($scope,$http) {
var url="http://52.74.160.253:8080/jobs/";
var LocalData = "data.txt";
$http.get(LocalData).success( function(response) {
$scope.jobs = response;
});
}
Now here is the weird part . I have the JSON data stored both locally and on the server , When i use the locally stored JSON data , it works fine . But when I use the url , I get displayed with an empty table .Both the local and url data are exactly the same .