相关疑难解决方法(0)

使用Pylint和Django

我非常希望将pylint集成到我的python项目的构建过程中,但是我遇到了一个show-stopper:我觉得非常有用的一种错误类型 - : - E1101: *%s %r has no %r member*在使用常见的django字段时会报告错误, 例如:

E1101:125:get_user_tags: Class 'Tag' has no 'objects' member
Run Code Online (Sandbox Code Playgroud)

这是由这段代码引起的:

def get_user_tags(username):
   """
   Gets all the tags that username has used.

   Returns a query set.
   """
   return Tag.objects.filter(  ## This line triggers the error.
       tagownership__users__username__exact=username).distinct()

# Here is the Tag class, models.Model is provided by Django:
class Tag(models.Model):
   """
   Model for user-defined strings that help categorize Events on
   on a per-user basis.
   """
   name = models.CharField(max_length=500, null=False, …
Run Code Online (Sandbox Code Playgroud)

python django static-analysis pylint

137
推荐指数
9
解决办法
4万
查看次数

标签 统计

django ×1

pylint ×1

python ×1

static-analysis ×1