【发布时间】:2019-11-19 10:37:42
【问题描述】:
我是 python 和 Django 的新手。
我尝试了几种解决堆栈溢出问题的方法,但仍然遇到同样的问题。我试过从 shell 查询,它运行良好,但不是在我的代码上。
我已经使用
安装了pylint
pip install pylint-django
我还将 Settings > User Settings > Python 上的 Linter 设置 从 pyLint 更改为 pylint_django 和 flake8,但没有积极的结果.
我仍然收到消息“课堂课程没有'对象'成员 pylint(no-member)”
这些是我在 models.py 中的代码:
class Courses(models.Model):
course_title = models.CharField(max_length=200)
course_image = models.ImageField(upload_to='course_images/')
course_duration = models.TimeField()
def __str__(self):
return self.course_title
views.py 看起来像这样:
from django.shortcuts import render
from django.http import HttpResponse
from .models import Courses
def homepage(request):
cos = Courses.objects.all()
context={ 'courses': cos }
return render(request, "main/home.html", context)
我需要帮助。我完全被困住了。
【问题讨论】:
标签: django django-models django-views django-queryset django-cms