Django, viewing models from different app
Question: I am super new to python programming and django and i got the basics out of
the way. I created a project with two apps, home and video. In my video
models.py i have the following data:

    
    
    class Video(models.Model):
        name = models.CharField(max_length=200)
        description = models.TextField(blank=True, null=True)
    

I want to do something with this in my home app in the views.py, such as
display the data in an html page and currently it is set up as followed:

    
    
    from video.models import Video
    
    def display_video(request):
        video_list = Video.objects.all()
        context = {'video_list': video_list}
        return render(request, 'home/home.html', context)
    

in my home.html

    
    
    {% if video_list %}
     {% for video in video_list %}
      <p>{{ video.name }}</p>
      <p>{{ video.description }}</p>
     {% endfor %}
    {% else %}
     <p>no videos to display</p>
    {% endif %}
    

my home.html always returns "no videos to display"

But when i query Video.objects.all() in my video app it finds 2 objects. any
help is appreciated.


Answer: In settings, check the following is there.

    
    
    TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
    ]
    

