| 1 |
""" |
| 2 |
Models for testing various aspects of the django.contrib.admindocs app. |
| 3 |
""" |
| 4 |
|
| 5 |
from django.db import models |
| 6 |
from django.utils.functional import cached_property |
| 7 |
|
| 8 |
|
| 9 |
class Company(models.Model): |
| 10 |
name = models.CharField(max_length=200) |
| 11 |
|
| 12 |
|
| 13 |
class Group(models.Model): |
| 14 |
name = models.CharField(max_length=200) |
| 15 |
|
| 16 |
|
| 17 |
class Family(models.Model): |
| 18 |
""" |
| 19 |
Links with different link text. |
| 20 |
|
| 21 |
This is a line with tag :tag:`extends <built_in-extends>` |
| 22 |
This is a line with model :model:`Family <myapp.Family>` |
| 23 |
This is a line with view :view:`Index <myapp.views.Index>` |
| 24 |
This is a line with template :template:`index template <Index.html>` |
| 25 |
This is a line with filter :filter:`example filter <filtername>` |
| 26 |
""" |
| 27 |
|
| 28 |
last_name = models.CharField(max_length=200) |
| 29 |
|
| 30 |
|
| 31 |
class Person(models.Model): |
| 32 |
""" |
| 33 |
Stores information about a person, related to :model:`myapp.Company`. |
| 34 |
|
| 35 |
**Notes** |
| 36 |
|
| 37 |
Use ``save_changes()`` when saving this object. |
| 38 |
|
| 39 |
``company`` |
| 40 |
Field storing :model:`myapp.Company` where the person works. |
| 41 |
|
| 42 |
(DESCRIPTION) |
| 43 |
|
| 44 |
.. raw:: html |
| 45 |
:file: admin_docs/evilfile.txt |
| 46 |
|
| 47 |
.. include:: admin_docs/evilfile.txt |
| 48 |
""" |
| 49 |
|
| 50 |
first_name = models.CharField(max_length=200, help_text="The person's first name") |
| 51 |
last_name = models.CharField(max_length=200, help_text="The person's last name") |
| 52 |
company = models.ForeignKey(Company, models.CASCADE, help_text="place of work") |
| 53 |
family = models.ForeignKey(Family, models.SET_NULL, related_name="+", null=True) |
| 54 |
groups = models.ManyToManyField(Group, help_text="has membership") |
| 55 |
|
| 56 |
def _get_full_name(self): |
| 57 |
return "%s %s" % (self.first_name, self.last_name) |
| 58 |
|
| 59 |
def rename_company(self, new_name): |
| 60 |
self.company.name = new_name |
| 61 |
self.company.save() |
| 62 |
return new_name |
| 63 |
|
| 64 |
def dummy_function(self, baz, rox, *some_args, **some_kwargs): |
| 65 |
return some_kwargs |
| 66 |
|
| 67 |
def dummy_function_keyword_only_arg(self, *, keyword_only_arg): |
| 68 |
return keyword_only_arg |
| 69 |
|
| 70 |
def all_kinds_arg_function(self, position_only_arg, /, arg, *, kwarg): |
| 71 |
return position_only_arg, arg, kwarg |
| 72 |
|
| 73 |
@property |
| 74 |
def a_property(self): |
| 75 |
return "a_property" |
| 76 |
|
| 77 |
@cached_property |
| 78 |
def a_cached_property(self): |
| 79 |
return "a_cached_property" |
| 80 |
|
| 81 |
def suffix_company_name(self, suffix="ltd"): |
| 82 |
return self.company.name + suffix |
| 83 |
|
| 84 |
def add_image(self): |
| 85 |
pass |
| 86 |
|
| 87 |
def delete_image(self): |
| 88 |
pass |
| 89 |
|
| 90 |
def save_changes(self): |
| 91 |
pass |
| 92 |
|
| 93 |
def set_status(self): |
| 94 |
pass |
| 95 |
|
| 96 |
def get_full_name(self): |
| 97 |
""" |
| 98 |
Get the full name of the person |
| 99 |
""" |
| 100 |
return self._get_full_name() |
| 101 |
|
| 102 |
def get_status_count(self): |
| 103 |
return 0 |
| 104 |
|
| 105 |
def get_groups_list(self): |
| 106 |
return [] |