# Django python clarification request

**URL:** <https://forum.codewithmosh.com/t/django-python-clarification-request/5819>\
**Category:** Python\
**Created:** [July 2, 2021, 1:36am UTC](https://forum.codewithmosh.com/t/django-python-clarification-request/5819 "2021-07-02T01:36:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![codestudent](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@codestudent](https://forum.codewithmosh.com/u/codestudent)\
**Post date:** [July 2, 2021, 1:36am UTC](https://forum.codewithmosh.com/t/django-python-clarification-request/5819/1 "2021-07-02T01:36:48Z")

</div>

RE: Python course, django section: 11- Templates

I do not understand the interaction between the views.py and index.html

My code for views.py was:  
def index(request1):  
movies1 = Movie.objects.all()  
return render(request1, ‘index1.html’, {‘movies’: movies1})

My code for index1.html was:

 {% for movie in movies1 %} {{ movie.title }} {{ movie.genre }} {{ movie.number\_in\_stock }} {{ movie.daily\_rate }} {% endfor %}

With the above code, I see no database results. However, when I change one line I get database results:  
{% for movie in movies %}  
How is this possible?

---

<div class="post-metadata">

**Author:** ![TaserFace20](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@TaserFace20](https://forum.codewithmosh.com/u/TaserFace20)\
**Post date:** [July 3, 2021, 4:11am UTC](https://forum.codewithmosh.com/t/django-python-clarification-request/5819/2 "2021-07-03T04:11:56Z")

</div>

> [@codestudent](#):
>
> {‘movies’: movies1}

In your views file you are storing the ‘movies1’ into the ‘movies’ key inside the dictionary. Then in the ‘index1.html’ you have to use the key (ie. movies).

I hope this clears it up. If you have any further questions then I’m more than happy to answer them.

P.S A pro tip is to create a dictionary called ‘context’, then use ‘context’ in the return statement.

```auto
def index(request):
    movies = Movie.objects.all()
    customers = Customers.objects.all()
    theatres = Theatres.objects.all()
    
    context = {
        'movies': movies,
        'customers': customers,
        'theatres': theatres,
    }
    return render(request, ‘index1.html’, context)

```
