In Django, on webpage it does not showing content for attribute we defined in model.py


please refer this picture I sent.

You need to attach the code for model and view… we cannot help you only looking at a screenshot

models.py

from django.db import models
from django.utils import timezone

class Genre(models.Model):
name = models.CharField(max_length=255)

def __str__(self):
    return self.name

class Movie(models.Model):
title = models.CharField(max_length=255)
release_year = models.IntegerField()
number_in_stock = models.IntegerField()
daily_rate = models.FloatField()
genre = models.ForeignKey(Genre, on_delete=models.CASCADE)
date_created = models.DateTimeField(default = timezone.now)

views.py:

from django.http import HttpResponse
from django.shortcuts import render
from movies.models import Movie

.

def index(request):
movies = Movie.objects.all()
return render(request,‘movies/index.html’,{‘movies’: movies})

def detail(request, movie_id):
movie = Movie.objects.get(pk = movie_id)
return render(request, ‘movies/detail.html’, {‘movies’:movie})

I think the problem is in the context you pass to the detail view:

movies’: movie

Maybe you’re referring to movie in the template but you pass movies

Check in the template…