Skip to content

Commit 93fd041

Browse files
committed
[refs #66] Testing to see if access to _meta on models is allowed
1 parent 8824af6 commit 93fd041

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Tests to make sure that access to _meta on a model does not raise
3+
a protected-access warning, as it is part of the public API since
4+
Django 1.8
5+
(see https://github.com/landscapeio/pylint-django/issues/66,
6+
and https://docs.djangoproject.com/en/1.9/ref/models/meta/)
7+
"""
8+
# pylint: disable=C0111,W5101,W5103
9+
from django.db import models
10+
11+
12+
class ModelWhichLikesMeta(models.Model):
13+
ursuary = models.BooleanField(default=False)
14+
15+
def do_a_thing(self):
16+
return self._meta.get_field('ursuary')
17+
18+
19+
if __name__ == '__main__':
20+
MODEL = ModelWhichLikesMeta()
21+
MODEL.save()
22+
print MODEL.do_a_thing()

0 commit comments

Comments
 (0)