models.py
class MyVideo(models.Model):
title = models.CharField(max_length=100, null=True, default='')
seotitle = models.CharField(max_length=100, null=True, default='')
keywords = models.CharField(max_length=150, null=True, default='')
status = models.IntegerField(default=1)
serializers.py
class MyVideoSerializer(serializers.ModelSerializer):
class Meta:
model = MyVideo
fields = '__all__'
views.py
class My(viewsets.ModelViewSet):
queryset = MyVideo.objects.all()
serializer_class = MyVideoSerializer
renderer_classes = (JSONRenderer, TemplateHTMLRenderer,)
template_name = "my.html"
def get(self, request, *args, **kwargs):
# ??????
def get_query(self):
# ??????
urls.py
urlpatterns = [
path('my/', views.My), # ???????? anything wrong here?
]
my.html
<html><body>
<h1>My video</h1>
<ul>
{% for d in data %}
<li>{{ d.title }}</li> # ?????? anything wrong here?
<li>{{ d.seotitle }}</li>
<li>{{ d.keywords }}</li>
{% endfor %}
</ul>
</body></html>
I have a MyVideo model which store several videos record in the database. What I wanna implement is that to display the information of those videos through the my.html.
e.g. http://127.0.0.1:8000/my/103 can access the video which id=103, and on this page display its fields (title, seotitle, keywords, etc.).
Any nice implementation or suggestion? Thanks!
**UPDATE
<html><body>
<h1>My video</h1>
<ul>
{{ data }}
</ul>
</body></html>

# ????What do you have there?