我在django收到此错误。
/ dog_list /中的OSError [Errno 22]无效的参数:“ C:\ Users \ Kanan \ Desktop \ blank \ cv \ templates \”
我的views.py文件就是这样
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from dog.models import User, Dog
from django.http import Http404
# Create your views here.
def dog(request):
context = {
"dog_list": Dog.objects.all()
}
return render('dog.html', request, context=context)
我的html文件就是这样
<html>
<head>
<title> Welcome to Dog sharing platform</title>
</head>
<body>
<h2> Dog types </h2>
<li>
{% for dog in dog_list %}
<ul>{{dog.dog_list}}</ul>
{% endfor %}
</li>
</body>
我的models.py文件在下面给出
class User(models.Model):
username = models.CharField(max_length=100)
def __str__(self):
return self.username
class Dog(models.Model):
breed = models.CharField(max_length=100)
name = models.CharField(max_length=100)
age = models.FloatField(default=0.5)
user = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.breed
我该如何解决?
答案 0 :(得分:1)
您的问题类似于: Django OSError [Errno 22] Invalid Argument
我认为您需要重新排列参数以呈现如下:
return render(request, 'dog.html', context=context)
祝你好运