2
def homepage(response):
    data = Project_types.objects.all()
    return render(response, 'main/homepage.html',{'projects':data})


def hacks(response):
    return render(response, 'main/hacks.html', {})

def games(response):
    return render(response, 'main/games.html', {})

All I need to know is how to iterate through each object in the variable "data" in html. I want it displayed in the most simple way possible !

2 Answers 2

5

Using the FOR template tags you can iterate through the objects in the data list ...

templatename.html:

{% for iteratorname in projects %}
    <h1> {{ iteratorname.attributes }} </h1>
{% endfor %}

Please read the documentation for more details

Sign up to request clarification or add additional context in comments.

1 Comment

@Selcuk ... Thanks.. did not see that !
1

You can use for template tag:

{% for project in projects %}
    <p> {{project.attributes}} </p>
{% endfor %}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.