Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我有一个PythonDjango应用程序,在Pylance自动安装之前一直运行良好。现在我得到一个错误:发生异常:_Python_Django - Fatal编程技术网

我有一个PythonDjango应用程序,在Pylance自动安装之前一直运行良好。现在我得到一个错误:发生异常:

我有一个PythonDjango应用程序,在Pylance自动安装之前一直运行良好。现在我得到一个错误:发生异常:,python,django,Python,Django,我的代码是: from django.shortcuts import render # Create your views here. from django.views.generic import ListView # <- new from .models import Post def home(request): context = { 'posts': Post.objects.all() } return ren

我的代码是:

from django.shortcuts import render         # Create your views here.
from django.views.generic import ListView   # <- new
from .models import Post

def home(request):
    context = {
        'posts': Post.objects.all()
    }
    return render(request, 'blog/home.html', context)

任何帮助都将不胜感激。

请共享异常的完整回溯。没有回溯。当我打开项目时,错误是Post下面的旋转线,表示它在view.py中找不到Post。它位于models.py文件中。错误是类“Post”没有“objects”memberpylint(没有成员)。
Post is defined in:
from django.db import models                         # Create your model fields here.
from django.utils import timezone                    # for the DateTimeZone field below
from django.contrib.auth.models import User          # the author field below needs this

class Post(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()                                 # TextField has no length limitation
    date_posted = models.DateTimeField(default=timezone.now)     # Use the django timezone
    author = models.ForeignKey(User, on_delete=models.CASCADE)   # if the User is deleted, so will this model

    def __str__(self):
        return self.title