File: func_noerror_models_py33.py

package info (click to toggle)
pylint-django 2.0.13-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: python: 1,807; sh: 13; makefile: 5
file content (31 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Checks that Pylint does not complain about a fairly standard
Django Model
"""
#  pylint: disable=missing-docstring
from django.db import models


class SomeModel(models.Model):
    class Meta:
        pass

    some_field = models.CharField(max_length=20)

    other_fields = models.ManyToManyField('AnotherModel')

    def stuff(self):
        try:
            print(self._meta)
            print(self.other_fields.all()[0])
        except self.DoesNotExist:
            print('does not exist')
        except self.MultipleObjectsReturned:
            print('lala')

        print(self.get_some_field_display())


class SubclassModel(SomeModel):
    class Meta:
        pass