403Webshell
Server IP : 66.29.132.122  /  Your IP : 18.119.135.53
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/pylint_django/tests/input/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/pylint_django/tests/input/func_noerror_foreignkeys.py
"""
Checks that Pylint does not complain about various
methods on Django model fields.
"""
#  pylint: disable=missing-docstring,wrong-import-position
from django.db import models
from django.db.models import ForeignKey, OneToOneField


class Genre(models.Model):
    name = models.CharField(max_length=100)


class Author(models.Model):
    author_name = models.CharField(max_length=100)


class ISBN(models.Model):
    value = models.CharField(max_length=100)


class Book(models.Model):
    book_name = models.CharField(max_length=100)
    # Check this works with and without `to` keyword
    author = models.ForeignKey(to="Author", on_delete=models.CASCADE)
    isbn = models.OneToOneField(to=ISBN, on_delete=models.CASCADE)
    genre = models.ForeignKey(Genre, on_delete=models.CASCADE)

    def get_isbn(self):
        return self.isbn.value

    def get_author_name(self):
        return self.author.author_name


class Fruit(models.Model):
    fruit_name = models.CharField(max_length=20)


class Seed(models.Model):
    fruit = ForeignKey(to=Fruit, on_delete=models.CASCADE)

    def get_fruit_name(self):
        return self.fruit.fruit_name


class User(models.Model):
    username = models.CharField(max_length=32)


class UserProfile(models.Model):
    user = OneToOneField(User, on_delete=models.CASCADE)

    def get_username(self):
        return self.user.username


class Human(models.Model):
    child = ForeignKey("self", on_delete=models.SET_NULL, null=True)
    parent = ForeignKey(to="self", on_delete=models.SET_NULL, null=True)

    def get_grandchild(self):
        return self.child.child

    def get_grandparent(self):
        return self.parent.parent


class UserPreferences(models.Model):
    """
    Used for testing FK which refers to another model by
    string, not model class, see
    https://github.com/PyCQA/pylint-django/issues/35
    """

    user = ForeignKey("User", on_delete=models.CASCADE)


class UserAddress(models.Model):
    user = OneToOneField(to="User", on_delete=models.CASCADE)
    line_1 = models.CharField(max_length=100)
    line_2 = models.CharField(max_length=100)
    city = models.CharField(max_length=100)
    postal_code = models.CharField(max_length=100)

Youez - 2016 - github.com/yon3zu
LinuXploit