2
Good morning guys, I’m having a little problem referencing my variable in the html of Django. I’m a beginner in the web part, I’m trying to create a site for a project, so during the html construction, I tried to perform a "for" reference to my view.py, but it does not find the text saved in the "Texts" variable".
Additional information
1) I’m working with Sublime Text 3.(If it makes a difference)
2) I have already added the plugins: Django, anaconda(configured), Css3, Html5 and ement.
Could help me understand this problem?
Follows html code:
</div>
<div class="container">
<div class="jumbotron page-header">
<h1>{{ title|capfirst }}</h1>
<p>
{% for item in texts %}
{{item}},
{% endfor %}
</p>
View.py from Django:
# coding=utf-8
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
texts = ['Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua']
context = {
'title':'django e-commerce',
'texts':texts
}
return render(request, 'index.html', context)
Grateful Sidon... I’m actually typing even though thanks for the comment I’ll check and fix. Grateful fellow.
– vic.py
If you do what I "said" you will get the desired result, without a shadow of a doubt
– Sidon
If the answer has been resolved, consider giving the acceptance in the question.
– Sidon
Erdão Sidon, yes the answer was very satisfactory... But as I said, I’m starting my life in Django... Soon she was creating a variable to test the use of templates in the framework. But she made it easy... Nothing like experienced colleagues. Big hug.
– vic.py
Then consider accepting the answer by clicking on the sign next to the number of votes. Thank you,
– Sidon
You saw in my example, I also create a variable, the same way you did.
– Sidon